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]

[PATCH] Fix PR54702 and LTO bootstrap (for me)


This fixes PR54702 and LTO bootstrap (well, at least I now survive
stage2 cc1 build).  We shouldn't enter builtins into the symtab
asm-name hash, too much code seems to be confused by that (at least
we should at most insert builtins with a set assembler name).

Smells somewhat LTO-ish, but well.

LTO bootstrap running on x86_64-unknown-linux-gnu, regtest pending.

Richard.

2012-09-25  Richard Guenther  <rguenther@suse.de>

	PR middle-end/54702
	* symtab.c (insert_to_assembler_name_hash): Do not insert builtins.
	(verify_symtab_base): Adjust.
	(unlink_from_assembler_name_hash): Likewise.

	* gcc.dg/lto/pr54702_0.c: New testcase.
	* gcc.dg/lto/pr54702_1.c: Likewise.

Index: gcc/symtab.c
===================================================================
*** gcc/symtab.c	(revision 191700)
--- gcc/symtab.c	(working copy)
*************** insert_to_assembler_name_hash (symtab_no
*** 106,111 ****
--- 106,113 ----
  {
    if (symtab_variable_p (node) && DECL_HARD_REGISTER (node->symbol.decl))
      return;
+   if (symtab_function_p (node) && DECL_BUILT_IN (node->symbol.decl))
+     return;
    gcc_checking_assert (!node->symbol.previous_sharing_asm_name
  		       && !node->symbol.next_sharing_asm_name);
    if (assembler_name_hash)
*************** insert_to_assembler_name_hash (symtab_no
*** 130,135 ****
--- 132,141 ----
  static void
  unlink_from_assembler_name_hash (symtab_node node)
  {
+   if (symtab_variable_p (node) && DECL_HARD_REGISTER (node->symbol.decl))
+     return;
+   if (symtab_function_p (node) && DECL_BUILT_IN (node->symbol.decl))
+     return;
    if (assembler_name_hash)
      {
        if (node->symbol.next_sharing_asm_name)
*************** verify_symtab_base (symtab_node node)
*** 622,628 ****
  	  hashed_node = hashed_node->symbol.next_sharing_asm_name;
  	}
        if (!hashed_node
!           && !(symtab_variable_p (node) || DECL_HARD_REGISTER (node->symbol.decl)))
  	{
            error ("node not found in symtab assembler name hash");
            error_found = true;
--- 628,635 ----
  	  hashed_node = hashed_node->symbol.next_sharing_asm_name;
  	}
        if (!hashed_node
!           && !(symtab_variable_p (node) && DECL_HARD_REGISTER (node->symbol.decl))
! 	  && !(symtab_function_p (node) && DECL_BUILT_IN (node->symbol.decl)))
  	{
            error ("node not found in symtab assembler name hash");
            error_found = true;
Index: gcc/testsuite/gcc.dg/lto/pr54702_0.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/pr54702_0.c	(revision 0)
--- gcc/testsuite/gcc.dg/lto/pr54702_0.c	(working copy)
***************
*** 0 ****
--- 1,10 ----
+ /* { dg-lto-do link } */
+ /* { dg-lto-options { { -O2 -flto -w } } } */
+ /* { dg-extra-ld-options { -r -nostdlib } } */
+ 
+ #include <stdlib.h>
+ void* f ()
+ {
+   void* p = malloc (1);
+   return p;
+ }
Index: gcc/testsuite/gcc.dg/lto/pr54702_1.c
===================================================================
*** gcc/testsuite/gcc.dg/lto/pr54702_1.c	(revision 0)
--- gcc/testsuite/gcc.dg/lto/pr54702_1.c	(working copy)
***************
*** 0 ****
--- 1,16 ----
+ int *b;
+ void *d;
+ int c;
+ static int *f1 ();
+ void f2 ()
+ {
+   int *a = f1 (0);
+ }
+ 
+ int *f1 (j)
+ {
+   b = malloc (0);
+   d = *malloc;
+   c = j;
+ }
+ 


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