https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127468
Bug ID: 127468
Summary: [17 Regression] ICE: SIGSEGV in gimple_location
(gimple.h:1947) with -ftree-slp-vectorize
-fsave-optimization-record
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Keywords: ice-on-valid-code
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: zsojka at seznam dot cz
Target Milestone: ---
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Created attachment 65627
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65627&action=edit
reduced testcase
Compiler output:
$ x86_64-pc-linux-gnu-gcc -O -ftree-slp-vectorize -fsave-optimization-record
testcase.c -wrapper valgrind,-q
==1865288== Invalid read of size 8
==1865288== at 0xF2D4BE: gimple_location (gimple.h:1947)
==1865288== by 0xF2D4BE: make_item_for_dump_gimple_stmt(gimple*, int,
dump_flag) (dumpfile.cc:641)
==1865288== by 0xF2DF15: dump_pretty_printer::decode_format(text_info*, char
const*, pp_token_list&) (dumpfile.cc:924)
==1865288== by 0x2CCC9F6: format_phase_2 (pretty-print.cc:2303)
==1865288== by 0x2CCC9F6: pretty_printer::format(text_info&)
(pretty-print.cc:1846)
==1865288== by 0xF2AD4C: pp_format (pretty-print.h:599)
==1865288== by 0xF2AD4C: dump_context::dump_printf_va(dump_metadata_t
const&, char const*, __va_list_tag (*) [1]) (dumpfile.cc:1038)
==1865288== by 0xF2B5BA: dump_printf_loc_va (dumpfile.cc:1061)
==1865288== by 0xF2B5BA: dump_printf_loc(dump_metadata_t const&,
dump_user_location_t const&, char const*, ...) (dumpfile.cc:1389)
==1865288== by 0x183F13E: vect_build_slp_tree_3(vec_info*,
vec<_stmt_vec_info*, va_heap, vl_ptr>, match_elt_t*, unsigned char*, bool*,
tree_node*, unsigned int*) (tree-vect-slp.cc:1530)
==1865288== by 0x183FDD4: vect_build_slp_tree_1(vec_info*, unsigned char*,
vec<_stmt_vec_info*, va_heap, vl_ptr>, match_elt_t*, bool*, tree_node**) [clone
.constprop.0] (tree-vect-slp.cc:1757)
==1865288== by 0x184BB2E: vect_build_slp_tree_2(vec_info*, _slp_tree*,
vec<_stmt_vec_info*, va_heap, vl_ptr>, match_elt_t*, unsigned int*, unsigned
int*, hash_map<vec<_stmt_vec_info*, va_heap, vl_ptr>, _slp_tree*,
simple_hashmap_traits<bst_traits, _slp_tree*> >*) (tree-vect-slp.cc:2193)
==1865288== by 0x185122B: vect_build_slp_tree(vec_info*,
vec<_stmt_vec_info*, va_heap, vl_ptr>, match_elt_t*, unsigned int*, unsigned
int*, hash_map<vec<_stmt_vec_info*, va_heap, vl_ptr>, _slp_tree*,
simple_hashmap_traits<bst_traits, _slp_tree*> >*) (tree-vect-slp.cc:2002)
==1865288== by 0x1854303: vect_build_slp_instance(vec_info*,
slp_instance_kind, vec<_stmt_vec_info*, va_heap, vl_ptr>&, vec<_stmt_vec_info*,
va_heap, vl_ptr>&, vec<tree_node*, va_heap, vl_ptr>&, unsigned int, unsigned
int*, hash_map<vec<_stmt_vec_info*, va_heap, vl_ptr>, _slp_tree*,
simple_hashmap_traits<bst_traits, _slp_tree*> >*, bool) (tree-vect-slp.cc:4338)
==1865288== by 0x185B1C9: vect_analyze_slp(vec_info*, unsigned int, bool)
(tree-vect-slp.cc:5985)
==1865288== by 0x1864A02: vect_slp_analyze_bb_1 (tree-vect-slp.cc:10445)
==1865288== by 0x1864A02: vect_slp_region (tree-vect-slp.cc:10555)
==1865288== by 0x1864A02: vect_slp_bbs(vec<basic_block_def*, va_heap,
vl_ptr> const&, loop*) (tree-vect-slp.cc:10778)
==1865288== Address 0x10 is not stack'd, malloc'd or (recently) free'd
==1865288==
during GIMPLE pass: slp
testcase.c: In function 'foo':
testcase.c:7:1: internal compiler error: Segmentation fault
7 | foo(C d)
| ^~~
0x2c5a15d internal_error(char const*, ...)
/repo/gcc-trunk/gcc/diagnostic-global-context.cc:787
0x14e45ef crash_signal
/repo/gcc-trunk/gcc/toplev.cc:325
0xf2d4be gimple_location(gimple const*)
/repo/gcc-trunk/gcc/gimple.h:1947
...
0x1864a02 vect_slp_bbs
/repo/gcc-trunk/gcc/tree-vect-slp.cc:10778
/repo/gcc-trunk/binary-trunk-20260918101139-r17-4410-gbca59752267990-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/17.0.0/cc1
-quiet -iprefix
/repo/gcc-trunk/binary-trunk-20260918101139-r17-4410-gbca59752267990-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../lib/gcc/x86_64-pc-linux-gnu/17.0.0/
testcase.c -quiet -dumpdir a- -dumpbase testcase.c -dumpbase-ext .c
-mtune=generic -march=x86-64 -O -ftree-slp-vectorize -fsave-optimization-record
-o /tmp/cckjsVYU.s
Please submit a full bug report, with preprocessed source (by using
-freport-bug).
Please include the complete backtrace with any bug report.
See <https://gcc.gnu.org/bugs/> for instructions.
$ x86_64-pc-linux-gnu-gcc -v
Using built-in specs.
COLLECT_GCC=/repo/gcc-trunk/binary-latest-amd64/bin/x86_64-pc-linux-gnu-gcc
COLLECT_LTO_WRAPPER=/repo/gcc-trunk/binary-trunk-20260918101139-r17-4410-gbca59752267990-checking-yes-rtl-df-extra-nobootstrap-amd64/bin/../libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /repo/gcc-trunk//configure --enable-languages=c,c++
--enable-valgrind-annotations --disable-nls --enable-checking=yes,rtl,df,extra
--disable-bootstrap --enable-libsanitizer --build=x86_64-pc-linux-gnu
--host=x86_64-pc-linux-gnu --target=x86_64-pc-linux-gnu
--with-ld=/usr/bin/x86_64-pc-linux-gnu-ld
--with-as=/usr/bin/x86_64-pc-linux-gnu-as --disable-libstdcxx-pch
--prefix=/repo/gcc-trunk//binary-trunk-20260918101139-r17-4410-gbca59752267990-checking-yes-rtl-df-extra-nobootstrap-amd64
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 17.0.0 20260918 (experimental) (GCC)