https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123736

            Bug ID: 123736
           Summary: ICE at -O1 with PGO on x86_64_linux-gnu: Segmentation
                    fault
           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 63433
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=63433&action=edit
The profile for PGO.

The ICE happens when I use the attached profile to compile small.c with PGO.
Both the test program and profile are reduced as much as possible.

To reproduce the ICE, put the attached profile (gcc-trunk.out-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=/home/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: /home/x27zhou/compiler-nightly/src/gcc/configure
--enable-checking=yes --disable-bootstrap --disable-multilib
--enable-languages=c,c++ --prefix=/home/x27zhou/compiler-nightly/install/gcc
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 16.0.1 20260120 (experimental) (GCC)
$
$
$ cat small.c
int a, c;
int *b;
static int realsmith_Wopq1() {
  int d, e;
  for (; d; ++d) {
    e = 0;
    for (; e < c; ++e)
      a = b[d];
  }
}
void realsmith_proxy_amGum() { realsmith_Wopq1(); }
void main() {}
$
$
$ gcc-trunk -O1 -fprofile-use -Wno-coverage-mismatch -o gcc-trunk.out small.c
small.c: In function ‘main’:
small.c:12:6: warning: profile for function ‘main’ not found in profile data
[-Wmissing-profile]
   12 | void main() {}
      |      ^~~~
during GIMPLE pass: unswitch
small.c: In function ‘realsmith_proxy_amGum’:
small.c:11:6: internal compiler error: Segmentation fault
   11 | void realsmith_proxy_amGum() { realsmith_Wopq1(); }
      |      ^~~~~~~~~~~~~~~~~~~~~
0x23a846f internal_error(char const*, ...)
       
/home/x27zhou/compiler-nightly/src/gcc/gcc/diagnostic-global-context.cc:787
0x1045b69 crash_signal(int)
        /home/x27zhou/compiler-nightly/src/gcc/gcc/toplev.cc:325
0x7f521475251f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x7f521478ff42 __GI__IO_fwrite
        ./libio/iofwrite.c:37
0x122f725 hoist_guard(loop*, edge_def*)
       
/home/x27zhou/compiler-nightly/src/gcc/gcc/tree-ssa-loop-unswitch.cc:1462
0x122f725 tree_unswitch_outer_loop(loop*)
       
/home/x27zhou/compiler-nightly/src/gcc/gcc/tree-ssa-loop-unswitch.cc:1105
0x122f725 tree_ssa_unswitch_loops(function*)
       
/home/x27zhou/compiler-nightly/src/gcc/gcc/tree-ssa-loop-unswitch.cc:340
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.

Reply via email to