https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124205
Bug ID: 124205
Summary: ICE at -O1 with PGO on x86_64_linux-gnu: Segmentation
fault during tree_profiling
Product: gcc
Version: 16.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: xintong.zhou1 at uwaterloo dot ca
Target Milestone: ---
Created attachment 63761
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63761&action=edit
The profile data for PGO.
The ICE happens when using the attached profile to compile small.c with PGO.
To reproduce the ICE, put the attached profile (a-small.gcda) in the same
directory as small.c and compile as follows:
$ gcc-trunk -v
Using built-in specs.
COLLECT_GCC=gcc-trunk
COLLECT_LTO_WRAPPER=/data/x27zhou/compiler-nightly/install/gcc/libexec/gcc/x86_64-pc-linux-gnu/16.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: /data/x27zhou/compiler-nightly/src/gcc/configure
--enable-checking=yes --disable-bootstrap --disable-multilib
--enable-languages=c,c++ --prefix=/data/x27zhou/compiler-nightly/install/gcc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.1 20260222 (experimental) (GCC)
$
$ cat small.c
int a, c, d, e;
int b() {
while (a)
;
return 0;
}
void f() {
if (b())
e = 2;
switch (c) {
case 2:
if (d)
e = 8;
break;
case 3:
if (d)
e = 0;
}
}
void main() {}
$
$
$ gcc-trunk -O1 -fprofile-use -fprofile-correction small.c
small.c: In function ‘main’:
small.c:20:6: warning: profile for function ‘main’ not found in profile data
[-Wmissing-profile]
20 | void main() {}
| ^~~~
during IPA pass: profile
small.c: In function ‘f’:
small.c:20:1: internal compiler error: Segmentation fault
20 | void main() {}
| ^~~~
0x23afabf internal_error(char const*, ...)
/data/x27zhou/compiler-nightly/src/gcc/gcc/diagnostic-global-context.cc:787
0x104aa59 crash_signal(int)
/data/x27zhou/compiler-nightly/src/gcc/gcc/toplev.cc:325
0x7fef0393551f ???
./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x210d919 find_fixup_edge(fixup_graph_type*, int, int)
/data/x27zhou/compiler-nightly/src/gcc/gcc/mcf.cc:425
0x210d919 cancel_negative_cycle(fixup_graph_type*, int*, long*, int*)
/data/x27zhou/compiler-nightly/src/gcc/gcc/mcf.cc:889
0x210d919 find_minimum_cost_flow(fixup_graph_type*)
/data/x27zhou/compiler-nightly/src/gcc/gcc/mcf.cc:1332
0x210d919 mcf_smooth_cfg()
/data/x27zhou/compiler-nightly/src/gcc/gcc/mcf.cc:1381
0xf1b7f7 compute_branch_probabilities(unsigned int, unsigned int)
/data/x27zhou/compiler-nightly/src/gcc/gcc/profile.cc:663
0xf189ff branch_prob(bool)
/data/x27zhou/compiler-nightly/src/gcc/gcc/profile.cc:1605
0x115acf5 tree_profiling()
/data/x27zhou/compiler-nightly/src/gcc/gcc/tree-profile.cc:1945
0x115acf5 (anonymous namespace)::pass_ipa_tree_profile::execute(function*)
/data/x27zhou/compiler-nightly/src/gcc/gcc/tree-profile.cc:2075
/data/x27zhou/compiler-nightly/install/gcc/libexec/gcc/x86_64-pc-linux-gnu/16.0.1/cc1
-quiet -imultiarch x86_64-linux-gnu small.c -quiet -dumpdir a- -dumpbase
small.c -dumpbase-ext .c -mtune=generic -march=x86-64 -O1 -fprofile-use
-fprofile-correction -o /tmp/cc6DO5F5.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.