This fixes PR55848, when doing LTO symtab merging as last resort
we should prefer a built-in decl if one is available as we are
not replacing its cgraph node.

Note, we still prefer a prevailing definition over a built-in
(which IMHO is good).

LTO bootstrap and regtest pending on x86_64-unknown-linux-gnu.

Richard.

2013-01-02  Richard Biener  <rguent...@suse.de>

        PR lto/55848
        * lto-symtab.c (lto_symtab_merge_decls_1): As last resort, always
        prefer a built-in decl.

Index: gcc/lto-symtab.c
===================================================================
*** gcc/lto-symtab.c    (revision 194787)
--- gcc/lto-symtab.c    (working copy)
*************** lto_symtab_merge_decls_1 (symtab_node fi
*** 439,444 ****
--- 439,454 ----
                && COMPLETE_TYPE_P (TREE_TYPE (e->symbol.decl)))
              prevailing = e;
        }
+       /* For variables prefer the builtin if one is available.  */
+       else if (TREE_CODE (prevailing->symbol.decl) == FUNCTION_DECL)
+       {
+         for (e = first; e; e = e->symbol.next_sharing_asm_name)
+           if (DECL_BUILT_IN (e->symbol.decl))
+             {
+               prevailing = e;
+               break;
+             }
+       }
      }
  
    symtab_prevail_in_asm_name_hash (prevailing);

Reply via email to