Hi,
this is a regression present on mainline and 4.7 branch. On the attached
testcase, the compiler aborts in LTO mode with:
eric@atlantis:~/build/gcc/native32> gcc/xgcc -Bgcc -S lto11.adb -O -flto
+===========================GNAT BUG DETECTED==============================+
| 4.8.0 20120506 (experimental) [trunk revision 187216] (i586-suse-linux)
| tree code 'call_expr' is not supported in LTO streams
The problem is that the Ada compiler started to use DECL_ORIGINAL_TYPE in 4.7.x
and the type in this field can have arbitrary expressions as TYPE_SIZE, for
example expressions with CALL_EXPRs. Now the type is both not gimplified and
streamed in LTO mode, so the CALL_EXPRs are sent to the streamer as-is.
The immediate solution would be not to stream DECL_ORIGINAL_TYPE (and clear it
in free_lang_data_in_decl), but this yields a regression in C++ with -flto -g
(ICE in splice_child_die). Therefore, the patch implements the alternate
solution of gimplifying DECL_ORIGINAL_TYPE.
Bootstrapped/regtested on x86_64-suse-linux, OK for mainline and 4.7 branch?
2012-05-09 Eric Botcazou <[email protected]>
* gimplify.c (gimplify_decl_expr): For a TYPE_DECL, gimplify the
DECL_ORIGINAL_TYPE if it is present.
2012-05-09 Eric Botcazou <[email protected]>
* gnat.dg/lto11.ad[sb]: New test.
--
Eric Botcazou
-- { dg-do compile }
-- { dg-options "-flto" { target lto } }
with Ada.Streams; use Ada.Streams;
package body Lto11 is
procedure Write
(S : not null access Root_Stream_Type'Class;
V : Vector)
is
subtype M_SEA is Stream_Element_Array (1 .. V'Size / Stream_Element'Size);
Bytes : M_SEA;
for Bytes'Address use V'Address;
pragma Import (Ada, Bytes);
begin
Ada.Streams.Write (S.all, Bytes);
end;
end Lto11;
with Ada.Streams; use Ada.Streams;
package Lto11 is
type Vector is array (Positive range <>) of Float;
procedure Write (S : not null access Root_Stream_Type'Class; V : Vector);
end Lto11;
diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index c4792e6..f69e773 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -1448,6 +1448,11 @@ gimplify_decl_expr (tree *stmt_p, gimple_seq *seq_p)
&& !TYPE_SIZES_GIMPLIFIED (TREE_TYPE (decl)))
gimplify_type_sizes (TREE_TYPE (decl), seq_p);
+ if (TREE_CODE (decl) == TYPE_DECL
+ && DECL_ORIGINAL_TYPE (decl)
+ && !TYPE_SIZES_GIMPLIFIED (DECL_ORIGINAL_TYPE (decl)))
+ gimplify_type_sizes (DECL_ORIGINAL_TYPE (decl), seq_p);
+
if (TREE_CODE (decl) == VAR_DECL && !DECL_EXTERNAL (decl))
{
tree init = DECL_INITIAL (decl);