Bug 68811 - [6 Regression] ICE: in get, at cgraph.h:1218
Summary: [6 Regression] ICE: in get, at cgraph.h:1218
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 6.0
Assignee: Jan Hubicka
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-12-09 09:14 UTC by Markus Trippelsdorf
Modified: 2015-12-09 23:36 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
reduced testcase (1.16 KB, application/x-tar)
2015-12-09 09:14 UTC, Markus Trippelsdorf
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Trippelsdorf 2015-12-09 09:14:31 UTC
Created attachment 36969 [details]
reduced testcase

Trying to build Firefox with LTO fails:

lto1: internal compiler error: in lto_symtab_prevail_decl, at lto/lto-symtab.h:33
0x1018d543 lto_symtab_prevail_decl
        ../../gcc/gcc/lto/lto-symtab.h:33
0x1018d543 lto_symtab_merge_decls_2
        ../../gcc/gcc/lto/lto-symtab.c:581
0x1018d543 lto_symtab_merge_decls_1
        ../../gcc/gcc/lto/lto-symtab.c:766
0x1018d543 lto_symtab_merge_decls()
        ../../gcc/gcc/lto/lto-symtab.c:789
0x1017ae6f read_cgraph_and_symbols
        ../../gcc/gcc/lto/lto.c:2881
0x1017ae6f lto_main()
        ../../gcc/gcc/lto/lto.c:3266

While reducing I hit another ICE:

trippels@gcc2-power8 app % g++ -w -flto -O2 test.ii test2.ii
lto1: internal compiler error: in get, at cgraph.h:1218
0x104c1ec7 cgraph_node::get(tree_node const*)
        ../../gcc/gcc/cgraph.h:1218
0x104c1ec7 symbol_table::remove_unreachable_nodes(_IO_FILE*)
        ../../gcc/gcc/ipa.c:370
0x1017a033 read_cgraph_and_symbols
        ../../gcc/gcc/lto/lto.c:2932
0x1017a033 lto_main()
        ../../gcc/gcc/lto/lto.c:3266

testcase is attached.
Comment 1 Jan Hubicka 2015-12-09 17:38:43 UTC
mine.
Comment 2 Jan Hubicka 2015-12-09 17:39:46 UTC
mine again.
Comment 3 Jan Hubicka 2015-12-09 17:58:06 UTC
The bug is that we can not prevail builtin decl refered by the global tables by non-builtin.  The following restores the previous behaviour of not merging. Next stage1 I can clean this up finally.
Index: lto-symtab.c
===================================================================
--- lto-symtab.c        (revision 231439)
+++ lto-symtab.c        (working copy)
@@ -514,11 +514,9 @@ lto_symtab_merge_p (tree prevailing, tre
     return false;
   if (TREE_CODE (prevailing) == FUNCTION_DECL)
     {
-      if (DECL_BUILT_IN (prevailing) != DECL_BUILT_IN (decl))
-       return false;
-      if (DECL_BUILT_IN (prevailing)
-         && (DECL_BUILT_IN_CLASS (prevailing) != DECL_BUILT_IN_CLASS (decl)
-             || DECL_FUNCTION_CODE (prevailing) != DECL_FUNCTION_CODE (decl)))
+      /* Never merge bulitin declarations. Those are streamed specially
+        and already merged from the corresponding tables.  */
+      if (DECL_BUILT_IN (prevailing) || DECL_BUILT_IN (decl))
        return false;
     }
   /* There are several other cases where merging can not be done, but until
@@ -709,7 +707,7 @@ lto_symtab_merge_decls_1 (symtab_node *f
                && lto_symtab_symbol_p (e))
              prevailing = e;
        }
-      /* For variables prefer the non-builtin if one is available.  */
+      /* For functions prefer the non-builtin if one is available.  */
       else if (TREE_CODE (prevailing->decl) == FUNCTION_DECL)
        {
          for (e = first; e; e = e->next_sharing_asm_name)
Comment 4 Jan Hubicka 2015-12-09 19:35:49 UTC
Author: hubicka
Date: Wed Dec  9 19:35:18 2015
New Revision: 231473

URL: https://gcc.gnu.org/viewcvs?rev=231473&root=gcc&view=rev
Log:

	PR lto/68811
	* g++.dg/lto/pr68811_0.C: New testcase.
	* g++.dg/lto/pr68811_1.C: New testcase.

	* lto-symtab.c (lto_symtab_merge_decls_2): Decl can never be prevailed
	by itself.

Added:
    trunk/gcc/testsuite/g++.dg/lto/pr68811_0.C
    trunk/gcc/testsuite/g++.dg/lto/pr68811_1.C
Modified:
    trunk/gcc/lto/ChangeLog
    trunk/gcc/lto/lto-symtab.c
    trunk/gcc/testsuite/ChangeLog
Comment 5 Markus Trippelsdorf 2015-12-09 20:01:33 UTC
Thanks.

I now get:

lto1: internal compiler error: in lto_fixup_prevailing_decls, at lto/lto.c:2533
0x1017ce37 lto_fixup_prevailing_decls
        ../../gcc/gcc/lto/lto.c:2533
0x1017ce37 lto_fixup_decls
        ../../gcc/gcc/lto/lto.c:2657
0x1017ce37 read_cgraph_and_symbols
        ../../gcc/gcc/lto/lto.c:2890
0x1017ce37 lto_main()
        ../../gcc/gcc/lto/lto.c:3266
Please submit a full bug report,
with preprocessed source if appropriate.
Please include the complete backtrace with any bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.
lto-wrapper: fatal error: ../../../gcc_test/usr/local/bin/c++ returned 1 exit status
compilation terminated.
/home/trippels/bin/ld: fatal error: lto-wrapper failed
collect2: error: ld returned 1 exit status
/home/trippels/gecko-dev/config/rules.mk:829: recipe for target 'libxul.so' failed
Comment 6 Jan Hubicka 2015-12-09 20:39:32 UTC
> Thanks.
> 
> I now get:
> 
> lto1: internal compiler error: in lto_fixup_prevailing_decls, at lto/lto.c:2533
> 0x1017ce37 lto_fixup_prevailing_decls
>         ../../gcc/gcc/lto/lto.c:2533

Fun, I wonder why I did not hit it.  The issue is that we try to
fixup decl that was prevailed.  I suppose we can just drop that sanity check.
We check this twice - doing that before symtab merging should be enough.

Honza
Comment 7 Jan Hubicka 2015-12-09 20:48:54 UTC
Hi,
does this patch fix the issue for you?

Honza

Index: lto/lto.c
===================================================================
--- lto/lto.c	(revision 231472)
+++ lto/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))
     {
Comment 8 Markus Trippelsdorf 2015-12-09 21:04:39 UTC
(In reply to Jan Hubicka from comment #7)
>
> does this patch fix the issue for you?

Yes, it does. Thanks!
Comment 9 Jan Hubicka 2015-12-09 22:37:34 UTC
Author: hubicka
Date: Wed Dec  9 22:37:02 2015
New Revision: 231477

URL: https://gcc.gnu.org/viewcvs?rev=231477&root=gcc&view=rev
Log:
	PR lto/68811
	* lto.c (lto_fixup_prevailing_decls): Do not check TREE_CHAIN of
	DECL.
	(LTO_NO_PREVAIL): Use gcc_checking_assert.

Modified:
    trunk/gcc/lto/ChangeLog
    trunk/gcc/lto/lto.c
Comment 10 Jan Hubicka 2015-12-09 23:36:40 UTC
Fixed.