https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97565
Bug ID: 97565 Summary: -flto -ipa-pta ICE: at cgraph_node::get_untransformed_body() Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: slyfox at gcc dot gnu.org CC: marxin at gcc dot gnu.org Target Milestone: --- This is a forward of https://bugs.gentoo.org/750473 ICE where spidermonkey-78.4.0 fails when built with -O1 flto -fipa-pta. Here is the "minimal" 2-file reproducer: // cat abort.cpp extern "C" void abort(void) { abort(); } // cat main.cpp extern "C" void abort(void); int main(int argc, char * argv[]) { abort(); } To crash it reliably on a small example I had to for LTO partitions to smallest sizes: $ x86_64-pc-linux-gnu-g++ -o abort.o -flto -O1 -fipa-pta --param=lto-min-partition=1 -flto-partition=max -c abort.cpp $ x86_64-pc-linux-gnu-g++ -o main.o -flto -O1 -fipa-pta --param=lto-min-partition=1 -flto-partition=max -c main.cpp $ x86_64-pc-linux-gnu-g++ -o o -flto -O1 -fipa-pta --param=lto-min-partition=1 -flto-partition=max main.o abort.o during IPA pass: pta lto1: internal compiler error: Segmentation fault 0xa798ba crash_signal /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/toplev.c:330 0x7fe1b23d4eef ??? /usr/src/debug/sys-libs/glibc-2.32-r2/glibc-2.32/signal/../sysdeps/unix/sysv/linux/x86_64/sigaction.c:0 0x6ab959 cgraph_node::get_untransformed_body() /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/cgraph.c:3934 0x6aba89 cgraph_node::get_body() /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/cgraph.c:3967 0xc2e433 ipa_pta_execute /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/tree-ssa-structalias.c:8150 0xc2e433 execute /usr/src/debug/sys-devel/gcc-11.0.0_pre9999/gcc-11.0.0_pre9999/gcc/tree-ssa-structalias.c:8569 Please submit a full bug report, It does not seem to be a regression. I see the same crash on g++-6.5.0 g++-7.5.0 g++-8.4.0 g++-9.3.0 g++-10.2.0 g++-11.0.0. It seems to have to do with a abort() symbol type. During LTO partition it's not consider either external or internal during partitioning: $ cat o.res 2 main.o 1 203 af1adcfd998498c1 PREVAILING_DEF main abort.o 1 201 8749e101441c301e PREVAILING_DEF_IRONLY_EXP abort I think we expect something like 'RESOLVED_IR abort' (or some form of external symbol?) for first 'main.o' partition. Otherwise crash happens when attempt to use the information around the symbol: Program received signal SIGSEGV, Segmentation fault. 0x000000000056f52a in cgraph_node::get_untransformed_body (this=0x7ffff744e2a0) at ../../gcc/gcc/cgraph.c:3920 3920 decl_state->compressed); (gdb) bt #0 0x000000000056f52a in cgraph_node::get_untransformed_body (this=0x7ffff744e2a0) at ../../gcc/gcc/cgraph.c:3920 #1 0x000000000056f6b8 in cgraph_node::get_body (this=0x7ffff744e2a0) at ../../gcc/gcc/cgraph.c:3951 #2 0x000000000101903a in ipa_pta_execute () at ../../gcc/gcc/tree-ssa-structalias.c:8154 #3 0x000000000101a6df in (anonymous namespace)::pass_ipa_pta::execute (this=0x2f09810) at ../../gcc/gcc/tree-ssa-structalias.c:8573 #4 0x0000000000b346b4 in execute_one_pass (pass=0x2f09810) at ../../gcc/gcc/passes.c:2517 #5 0x0000000000b35635 in execute_ipa_pass_list (pass=0x2f09810) at ../../gcc/gcc/passes.c:2944 #6 0x0000000000582fc4 in symbol_table::compile (this=0x7ffff7646100) at ../../gcc/gcc/cgraphunit.c:2805 #7 0x000000000043ba1b in lto_main () at ../../gcc/gcc/lto/lto.c:653 #8 0x0000000000cbd763 in compile_file () at ../../gcc/gcc/toplev.c:460 #9 0x0000000000cc0b25 in do_compile () at ../../gcc/gcc/toplev.c:2321 #10 0x0000000000cc0e3e in toplev::main (this=0x7fffffffd4a6, argc=20, argv=0x2ee3a10) at ../../gcc/gcc/toplev.c:2460 #11 0x0000000001f614e3 in main (argc=20, argv=0x7fffffffd5b8) at ../../gcc/gcc/main.c:39 (gdb) list 3915 origin = origin->clone_of; 3916 3917 int stream_order = origin->order - file_data->order_base; 3918 data = lto_get_section_data (file_data, LTO_section_function_body, 3919 name, stream_order, &len, 3920 decl_state->compressed); 3921 if (!data) 3922 fatal_error (input_location, "%s: section %s.%d is missing", 3923 file_data->file_name, name, stream_order); 3924 (gdb) print decl_state $1 = (lto_in_decl_state *) 0x0