https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106103
Bug ID: 106103 Summary: ICE in binds_to_current_def_p when source object files are compiled with -flto -Os Product: gcc Version: 12.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: ivanka2012 at gmail dot com CC: marxin at gcc dot gnu.org Target Milestone: --- Host: x86_64-build_pc-linux-gnu Target: x86_64-w64-mingw32 Build: x86_64-build_pc-linux-gnu Created attachment 53209 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=53209&action=edit Source code that contains alc.cpp.ii, buffer.cpp.ii and openal-info.c.i Compile the attached source files in the archive with the following commands: x86_64-w64-mingw32-g++ -flto -Os -std=gnu++14 -o alc.o -c alc.cpp.ii x86_64-w64-mingw32-g++ -flto -Os -std=gnu++14 -o buffer.o -c buffer.cpp.ii x86_64-w64-mingw32-gcc -flto -Os -std=gnu11 -o openal-info.o -c openal-info.c.i x86_64-w64-mingw32-g++ -r openal-info.o buffer.o alc.o -o /dev/null -lkernel32 The linker will yield the following: during GIMPLE pass: dse alc.cpp.ii: In function 'alcGetString': alc.cpp.ii:1167:13: internal compiler error: in binds_to_current_def_p, at symtab.cc:2494 1167 | const char *alcGetString() try { | ^ 0x681fd1 symtab_node::binds_to_current_def_p(symtab_node*) /x/crosstool-ng/.build/x86_64-w64-mingw32/src/gcc/gcc/symtab.cc:2494 0xc5a980 ref_maybe_used_by_call_p_1 /x/crosstool-ng/.build/x86_64-w64-mingw32/src/gcc/gcc/tree-ssa-alias.cc:2804 0xc5c137 ref_maybe_used_by_call_p /x/crosstool-ng/.build/x86_64-w64-mingw32/src/gcc/gcc/tree-ssa-alias.cc:2929 0xc5c137 ref_maybe_used_by_stmt_p(gimple*, ao_ref*, bool) /x/crosstool-ng/.build/x86_64-w64-mingw32/src/gcc/gcc/tree-ssa-alias.cc:2961 0xc7e517 dse_classify_store(ao_ref*, gimple*, bool, simple_bitmap_def*, bool*, tree_node*) /x/crosstool-ng/.build/x86_64-w64-mingw32/src/gcc/gcc/tree-ssa-dse.cc:981 0xc7ff76 dse_optimize_stmt /x/crosstool-ng/.build/x86_64-w64-mingw32/src/gcc/gcc/tree-ssa-dse.cc:1385 0xc7ff76 execute /x/crosstool-ng/.build/x86_64-w64-mingw32/src/gcc/gcc/tree-ssa-dse.cc:1491 The compiler is configured with the following flags: --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=x86_64-w64-mingw32 --prefix=/prefix --exec_prefix=/prefix --with-sysroot=/prefix/x86_64-w64-mingw32/sysroot --enable-languages=c,c++,fortran --with-pkgversion='crosstool-NG 1.25.0.40_994767d' --disable-shared --enable-__cxa_atexit --disable-libmudflap --disable-libgomp --disable-libssp --disable-libquadmath --disable-libquadmath-support --disable-libsanitizer --disable-libmpx --disable-libstdcxx-verbose --with-gmp=/x/crosstool-ng/.build/x86_64-w64-mingw32/buildtools --with-mpfr=/x/crosstool-ng/.build/x86_64-w64-mingw32/buildtools --with-mpc=/x/crosstool-ng/.build/x86_64-w64-mingw32/buildtools --with-isl=/x/crosstool-ng/.build/x86_64-w64-mingw32/buildtools --enable-lto --enable-threads=posix --enable-target-optspace --enable-plugin --disable-nls --enable-multiarch --with-local-prefix=/prefix/x86_64-w64-mingw32/sysroot --enable-long-long However, this was supplied by crosstool-ng, which I used to compile the toolchain. You might need to use that instead. The toolchain can be compiled with crosstool-ng using the following: ./ct-ng x86_64-w64-mingw32 ./ct-ng build I also set the prefix to something more reasonable and all compiler and linker flags were set to be '-g' but nothing else. Notes: This is already the most minimal possible test case. I tried fiddling with the compiler and linker flags and the above combination is the most minimal one that produces the ICE. The source code has also been processed with cvise for several days. I also observed this ICE in the "alias" GIMPLE pass in other test cases that are not included here since I haven't reduced those.