Hi,
this patch fixes ICE in lto.c caused by the (ab)use of TREE_CHAIN
by lto_symtab_prevail_decl.  We check twice that TREE_CHAIN does not
point to a decl - once before merging and once after.  It is sufficient
to do it once.  I also noticed that LTO_NO_PREVAIL use gcc_assert
and replaced it by gcc_checking_assert so lto_fixup_prevailing_decls
gets faster. It shows in the profiles.

Bootstrapped/regtsted x86_64-linux and Markus tested it fixes the
Firefox for him. Comitted.

Honza

Index: ChangeLog
===================================================================
--- ChangeLog   (revision 231473)
+++ ChangeLog   (working copy)
@@ -1,6 +1,13 @@
 2015-12-08  Jan Hubicka  <hubi...@ucw.cz>
 
        PR lto/68811
+       * lto.c (lto_fixup_prevailing_decls): Do not check TREE_CHAIN of
+       DECL.
+       (LTO_NO_PREVAIL): Use gcc_checking_assert.
+
+2015-12-08  Jan Hubicka  <hubi...@ucw.cz>
+
+       PR lto/68811
        * lto-symtab.c (lto_symtab_merge_decls_2): Decl can never be prevailed
        by itself.
 
Index: lto.c
===================================================================
--- lto.c       (revision 231472)
+++ lto.c       (working copy)
@@ -2517,7 +2517,7 @@ lto_wpa_write_files (void)
 
 /* Ensure that TT isn't a replacable var of function decl.  */
 #define LTO_NO_PREVAIL(tt) \
-  gcc_assert (!(tt) || !VAR_OR_FUNCTION_DECL_P (tt))
+  gcc_checking_assert (!(tt) || !VAR_OR_FUNCTION_DECL_P (tt))
 
 /* Given a tree T replace all fields referring to variables or functions
    with their prevailing variant.  */
@@ -2529,7 +2529,10 @@ lto_fixup_prevailing_decls (tree t)
 
   gcc_checking_assert (code != TREE_BINFO);
   LTO_NO_PREVAIL (TREE_TYPE (t));
-  if (CODE_CONTAINS_STRUCT (code, TS_COMMON))
+  if (CODE_CONTAINS_STRUCT (code, TS_COMMON)
+      /* lto_symtab_prevail_decl use TREE_CHAIN to link to the prevailing decl.
+        in the case T is a prevailed declaration we would ICE here. */
+      && !VAR_OR_FUNCTION_DECL_P (t))
     LTO_NO_PREVAIL (TREE_CHAIN (t));
   if (DECL_P (t))
     {

Reply via email to