https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91767
Bug ID: 91767 Summary: After r274953, clang-compiled xgcc segfaults during RTL pass: stv Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: bootstrap Assignee: unassigned at gcc dot gnu.org Reporter: dimitry at andric dot com Target Milestone: --- As reported in https://bugs.freebsd.org/240387, after the gcc10-devel port was updated from the 20190825 snapshot to the 20190901 snapshot, bootstrapping started to fail due to a segfault, when the host compiler is clang 8.0. Bisecting showed that the segfaults start appearing after r274953. The error appears for different source files, when building libgcc with xgcc, but it always looks like: during RTL pass: stv /home/dim/src/gcc/libgcc/config/libbid/bid128_fma.c: In function 'bid128_ext_fma': /home/dim/src/gcc/libgcc/config/libbid/bid128_fma.c:3569:1: internal compiler error: Segmentation fault 3569 | } | ^ Running under valgrind shows: ==19771== Invalid read of size 1 ==19771== at 0x82D7DC: gen_rtx_SUBREG(machine_mode, rtx_def*, poly_int<1u, unsigned long>) (src/gcc/gcc/emit-rtl.c:1013) ==19771== by 0xFFE42E: make_vector_copies (src/gcc/gcc/config/i386/i386-features.c:716) ==19771== by 0xFFE42E: (anonymous namespace)::general_scalar_chain::convert_registers() (src/gcc/gcc/config/i386/i386-features.c:1173) ==19771== by 0xFFC3B8: convert (src/gcc/gcc/config/i386/i386-features.c:1192) ==19771== by 0xFFC3B8: convert_scalars_to_vector (src/gcc/gcc/config/i386/i386-features.c:1629) ==19771== by 0xFFC3B8: (anonymous namespace)::pass_stv::execute(function*) (src/gcc/gcc/config/i386/i386-features.c:1767) ==19771== by 0xB3463D: execute_one_pass(opt_pass*) (src/gcc/gcc/passes.c:2494) ==19771== by 0xB35047: execute_pass_list_1(opt_pass*) (src/gcc/gcc/passes.c:2580) ==19771== by 0xB35059: execute_pass_list_1(opt_pass*) (src/gcc/gcc/passes.c:2581) ==19771== by 0xB27164: execute_pass_list(function*, opt_pass*) (src/gcc/gcc/passes.c:2591) ==19771== by 0x768E5A: cgraph_node::expand() (src/gcc/gcc/cgraphunit.c:2194) ==19771== by 0x76C4DD: expand_all_functions (src/gcc/gcc/cgraphunit.c:2332) ==19771== by 0x76C4DD: symbol_table::compile() (src/gcc/gcc/cgraphunit.c:2688) ==19771== by 0x76CA4F: symbol_table::finalize_compilation_unit() (src/gcc/gcc/cgraphunit.c:2868) ==19771== by 0xC150F3: compile_file() (src/gcc/gcc/toplev.c:481) ==19771== by 0xC14BCE: do_compile (src/gcc/gcc/toplev.c:2166) ==19771== by 0xC14BCE: toplev::main(int, char**) (src/gcc/gcc/toplev.c:2301) ==19771== Address 0x2 is not stack'd, malloc'd or (recently) free'd ==19771== Unfortunately this does not give much more information than simply running under gdb. It looks like an entry in a hash map is searched for, but unexpectedly returns NULL. This NULL value is then passed as a rtx_def pointer to gen_rtx_SUBREG(), which attempts to access one of the struct elements, and this causes the segfault.