https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120750
Bug ID: 120750
Summary: SEGV in remove_use, at rtl-ssa/accesses.cc:1276
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: ondrejmachota at gmail dot com
CC: rsandifo at gcc dot gnu.org
Target Milestone: ---
Hi,
Jan Hubicka <[email protected]> and I are working on a new RTL DCE pass based on
the RTL SSA framework.
To help reproduce this bug, we have provided a branch:
refs/users/omachota/heads/rtl-ssa-dce (commit: eb73be9bde7). We tested our DCE
implementation agains UD_DCE, which deleted the same instructions in both
provided testcases.
Reduced testcase (testcase_pr72742.i):
int a, b;
short c;
short *bar_y;
void bar() {
lab:
short va;
c %= a;
if (a & (b ? *bar_y : 4))
va += va;
a = va && a;
goto lab;
}
Run: gcc -c testcase_pr72742.i -O2
Compiler output:
during RTL pass: rtl_ssa_dce
testcase_pr72742.i: In function 'bar':
testcase_pr72742.i:12:1: internal compiler error: Segmentation fault
12 | }
| ^
0x2210511 internal_error(char const*, ...)
../../gcc/gcc/diagnostic-global-context.cc:517
0xd95f4f crash_signal
../../gcc/gcc/toplev.cc:322
0x2084d4e pointer_mux<rtl_ssa::use_info, rtl_ssa::use_info>::known_first()
const
../../gcc/gcc/mux-utils.h:87
0x2084d4e rtl_ssa::use_info::last_use() const
../../gcc/gcc/rtl-ssa/member-fns.inl:148
0x2084d4e rtl_ssa::function_info::remove_use(rtl_ssa::use_info*)
../../gcc/gcc/rtl-ssa/accesses.cc:1276
0x21ca98e rtl_ssa::function_info::delete_phi(rtl_ssa::phi_info*)
../../gcc/gcc/rtl-ssa/blocks.cc:402
0x208ac7b
rtl_ssa::function_info::process_uses_of_deleted_def(rtl_ssa::set_info*)
../../gcc/gcc/rtl-ssa/changes.cc:272
0x208de66
rtl_ssa::function_info::change_insns(array_slice<rtl_ssa::insn_change*>)
../../gcc/gcc/rtl-ssa/changes.cc:863
0x1ef8328 sweep
../../gcc/gcc/dce.cc:1675
0x1ef8328 execute
../../gcc/gcc/dce.cc:1709
0x1ef8328 execute
../../gcc/gcc/dce.cc:1747
Compiler details:
Using built-in specs.
COLLECT_GCC=/mnt/tmpfs/gcc-install/usr/local/bin/gcc
COLLECT_LTO_WRAPPER=/mnt/tmpfs/gcc-install/usr/local/bin/../libexec/gcc/x86_64-pc-linux-gnu/15.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc/configure --enable-languages=c,c++ --disable-bootstrap
--disable-multilib --disable-libquadmath --disable-nls --disable-lto
--disable-shared --disable-threads
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 15.0.1 20250123 (experimental) (GCC)
Compiling GCC from the provided branch may fail. You might need to disable the
rtl_ssa_dce
pass, compile GCC, then re-enable the pass and compile again.
One more reduced testcase (931102-1.i):
int e_a;
void e() {
int d;
char b;
switch (e_a)
case 1: {
d |= e_a;
if (b)
e();
do
if (d > b++)
d |= e_a;
while (1);
}
}
Run: gcc -c 931102-1.i -O1
Compiler output:
during RTL pass: rtl_ssa_dce
931102-1.i: In function 'e':
931102-1.i:15:1: internal compiler error: Segmentation fault
15 | }
| ^
0x2210511 internal_error(char const*, ...)
../../gcc/gcc/diagnostic-global-context.cc:517
0xd95f4f crash_signal
../../gcc/gcc/toplev.cc:322
0x2084d4e pointer_mux<rtl_ssa::use_info, rtl_ssa::use_info>::known_first()
const
../../gcc/gcc/mux-utils.h:87
0x2084d4e rtl_ssa::use_info::last_use() const
../../gcc/gcc/rtl-ssa/member-fns.inl:148
0x2084d4e rtl_ssa::function_info::remove_use(rtl_ssa::use_info*)
../../gcc/gcc/rtl-ssa/accesses.cc:1276
0x21ca98e rtl_ssa::function_info::delete_phi(rtl_ssa::phi_info*)
../../gcc/gcc/rtl-ssa/blocks.cc:402
0x208ac7b
rtl_ssa::function_info::process_uses_of_deleted_def(rtl_ssa::set_info*)
../../gcc/gcc/rtl-ssa/changes.cc:272
0x208de66
rtl_ssa::function_info::change_insns(array_slice<rtl_ssa::insn_change*>)
../../gcc/gcc/rtl-ssa/changes.cc:863
0x1ef8328 sweep
../../gcc/gcc/dce.cc:1675
0x1ef8328 execute
../../gcc/gcc/dce.cc:1709
0x1ef8328 execute
../../gcc/gcc/dce.cc:1747