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.
mine.
mine again.
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)
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
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
> 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
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)) {
(In reply to Jan Hubicka from comment #7) > > does this patch fix the issue for you? Yes, it does. Thanks!
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
Fixed.