This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[lto] Fix some libstdc++ tests with -flto


When building the libstdc++ support files with -flto, we were
failing with this ICE:

$  ./cc1plus -fpreprocessed testsuite_shared.ii
-quiet -dumpbase testsuite_shared.cc -mtune=generic -auxbase testsuite_shared -g -g -O2 -O2 -O2 -w -version -fmessage-length=0 -ffunction-sections -fdata-sections -fPIC -flto -o testsuite_shared.s
$  /home/dnovillo/lto/native/bld/./gcc/lto1 -quiet -dumpbase testsuite_shared.o -mtune=generic -auxbase-strip /tmp/ccwBWTQl.lto.o -g -g -O2 -O2 -O2 -w -version -fmessage-length=0 -ffunction-sections -fdata-sections -fPIC testsuite_shared.o -o testsuite_shared.s
GNU GIMPLE (lto merged with rev 140208) version 4.4.0 20080910 (experimental) (x86_64-unknown-linux-gnu)
       compiled by GNU C version 4.4.0 20080910 (experimental), GMP version 4.2.2, MPFR version 2.3.0-p2.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
lto1: internal compiler error: in lto_symtab_prevailing_decl, at lto/lto-symtab.c:574

The problem here is that in input_var_decl we were only handling
TREE_PUBLIC symbols if they were also globals (which is not the
case with static class members).

Fixing this bug, uncovered another in the writing of EH region
numbers.  When transitioning out of a region, we were writing 0
for the remaining statements in the basic block, which meant that
they were being associated with the last EH region written.

Tested on x86 and x86_64.


Diego.

	* lto-function-out.c (output_bb): Fix generation of EH
	region numbers when transitioning outside a region.
	* lto-function-in.c (input_var_decl): Do not force
	TREE_STATIC on global symbols.
	Handle TREE_PUBLIC decls even if they have a context.

lto/ChangeLog:

	* lto-symtab.c (lto_symtab_merge_decl): Do not force
	TREE_STATIC on global symbols.

Index: lto-function-out.c
===================================================================
--- lto-function-out.c	(revision 141130)
+++ lto-function-out.c	(working copy)
@@ -1899,28 +1899,23 @@ output_bb (struct output_block *ob, basi
 	 with a zero.  */
       for (bsi = gsi_start_bb (bb); !gsi_end_p (bsi); gsi_next (&bsi))
 	{
+	  int region;
 	  gimple stmt = gsi_stmt (bsi);
 
 	  output_gimple_stmt (ob, stmt);
 	
-	  /* We only need to set the region number of a statement that
-	     could throw if the region number is different from the
-	     last region number we set.  */
-	  if (stmt_could_throw_p (stmt))
+	  /* Emit the EH region holding STMT.  If the EH region is the
+	     same as the previous statement, emit a 0 for brevity.  */
+	  region = lookup_stmt_eh_region_fn (fn, stmt);
+	  if (region != last_eh_region_seen)
 	    {
-	      int region = lookup_stmt_eh_region_fn (fn, stmt);
-	      if (region != last_eh_region_seen)
-		{
-		  output_record_start (ob, NULL, NULL,
-				       LTO_set_eh0 + (region ? 1 : 0));
-		  if (region)
-		    output_sleb128 (ob, region);
-		
-		  last_eh_region_seen = region;
-		  LTO_DEBUG_UNDENT ();
-		}
-	      else
-		output_zero (ob);
+	      output_record_start (ob, NULL, NULL,
+				   LTO_set_eh0 + (region ? 1 : 0));
+	      if (region)
+		output_sleb128 (ob, region);
+
+	      last_eh_region_seen = region;
+	      LTO_DEBUG_UNDENT ();
 	    }
 	  else
 	    output_zero (ob);
Index: lto-function-in.c
===================================================================
--- lto-function-in.c	(revision 141130)
+++ lto-function-in.c	(working copy)
@@ -2932,25 +2932,17 @@ input_var_decl (struct lto_input_block *
       
 	  ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
 	  SET_DECL_ASSEMBLER_NAME (decl, get_identifier (label));
-
-          rest_of_decl_compilation (decl,
-                                    /*top_level=*/1,
-                                    /*at_end=*/0);
+          rest_of_decl_compilation (decl, 1, 0);
         }
+    }
 
-      /* FIXME lto: The DWARF reader always sets DECL_STATIC for a
-	 global, and lto_symtab_merge will assert if it is not set.
-         We should likely not set it, and fix lto_symtab_merge.  */
-      TREE_STATIC (decl) = 1;
-
-      /* If this variable has already been declared, merge the
-         declarations.  */
-      if (TREE_PUBLIC (decl))
-	{
-	  enum ld_plugin_symbol_resolution resolution =
-	    get_resolution (data_in, index);
-	  lto_symtab_merge_var (decl, resolution);
-	}
+  /* If this variable has already been declared, merge the
+     declarations.  */
+  if (TREE_PUBLIC (decl))
+    {
+      enum ld_plugin_symbol_resolution resolution;
+      resolution = get_resolution (data_in, index);
+      lto_symtab_merge_var (decl, resolution);
     }
 
   decl->decl_common.initial = input_tree (ib, data_in);
Index: lto/lto-symtab.c
===================================================================
--- lto/lto-symtab.c	(revision 141130)
+++ lto/lto-symtab.c	(working copy)
@@ -475,7 +475,6 @@ lto_symtab_merge_decl (tree new_decl,
   /*gcc_assert (!DECL_NONLOCAL (new_decl));*/
   if (TREE_CODE (new_decl) == VAR_DECL)
     {
-      gcc_assert (TREE_STATIC (new_decl));
       gcc_assert (!DECL_REGISTER (new_decl));
       gcc_assert (!(DECL_EXTERNAL (new_decl) && DECL_INITIAL (new_decl)));
     }
@@ -486,6 +485,7 @@ lto_symtab_merge_decl (tree new_decl,
   /* Retrieve the previous declaration.  */
   name = DECL_ASSEMBLER_NAME (new_decl);
   old_decl = LTO_IDENTIFIER_DECL (name);
+
   /* If there was no previous declaration, then there is nothing to
      merge.  */
   if (!old_decl)
@@ -566,7 +566,7 @@ lto_symtab_prevailing_decl (tree decl)
   if (!TREE_PUBLIC (decl))
     return decl;
 
-  /* LTO FIXME: There should be no DECL_ABSTRACT in the middle end. */
+  /* FIXME lto. There should be no DECL_ABSTRACT in the middle end. */
   if (TREE_CODE (decl) == FUNCTION_DECL && DECL_ABSTRACT (decl))
     return decl;
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]