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

            Bug ID: 126432
           Summary: ICE on valid code at -O3 with "-g -fno-tree-vrp -flto"
                    on x86_64-linux-gnu: Segmentation fault
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: lto
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zhendong.su at inf dot ethz.ch
  Target Milestone: ---

Compiler Explorer: https://godbolt.org/z/9bKG7z3ns

Note:
- fails: trunk
- works: 16.1 and earlier

[517] % gcctk -v
Using built-in specs.
COLLECT_GCC=gcctk
COLLECT_LTO_WRAPPER=/local/home/suz/suz-local/software/local/gcc-trunk/bin/../libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../gcc-trunk/configure --disable-bootstrap
--enable-checking=yes --prefix=/local/suz-local/software/local/gcc-trunk
--enable-sanitizers --enable-languages=c,c++,lto --disable-werror
--disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 17.0.0 20260726 (experimental) [master r17-1628-gd1c12591336] (GCC) 
[518] % 
[518] % gcctk -O3 -g -fno-tree-vrp -flto small.c
during IPA pass: modref
lto1: internal compiler error: Segmentation fault
0x25f453b internal_error(char const*, ...)
        ../../gcc-trunk/gcc/diagnostic-global-context.cc:787
0x107f643 crash_signal
        ../../gcc-trunk/gcc/toplev.cc:325
0x7fe9b7a4532f ???
        ./signal/../sysdeps/unix/sysv/linux/x86_64/libc_sigaction.c:0
0x21c4e49 contains_struct_check(tree_node*, tree_node_structure_enum, char
const*, int, char const*)
        ../../gcc-trunk/gcc/tree.h:3955
0x21c4e49 ipacp_value_safe_for_type(tree_node*, tree_node*)
        ../../gcc-trunk/gcc/ipa-cp.cc:1552
0xdbf0b3 compute_parm_map
        ../../gcc-trunk/gcc/ipa-modref.cc:4339
0xdc1b62 compute_parm_map
        ../../gcc-trunk/gcc/ipa-modref.cc:4308
0xdc1b62 modref_propagate_in_scc
        ../../gcc-trunk/gcc/ipa-modref.cc:4927
0xdc262f execute
        ../../gcc-trunk/gcc/ipa-modref.cc:5604
/local/home/suz/suz-local/software/local/gcc-trunk/bin/../lib/gcc/../../libexec/gcc/x86_64-pc-linux-gnu/17.0.0/lto1
-quiet -dumpbase ./a.wpa -mtune=generic -march=x86-64 -g -g -O3 -O3 -fno-openmp
-fno-openacc -fno-pie -fcf-protection=none -fno-tree-vrp
-fltrans-output-list=/tmp/ccZM88no.ltrans.out -fwpa
-fresolution=/tmp/ccnSrdQc.res -flinker-output=exec @/tmp/ccEV3cKn
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.
lto-wrapper: fatal error: gcctk returned 1 exit status
compilation terminated.
/usr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status
[519] % 
[519] % cat small.c
extern void ad();
extern void ak();
extern int ar();
unsigned a;
short d, e, f;
int g, h, c, ac;
long k, m, *ae, n, *z;
double ah;
__attribute__((__vector_size__(sizeof(double)))) double ao;
short *as, *at;
int l(int, int) {
  static unsigned af[6];
  for (unsigned i; i;)
    for (int j; j;)
      af[i] = c;
  for (unsigned b; b;) {
    char ag = a = a >> 8 ^ af[a ^ ag & 5];
  }
  return a;
}
int o(int);
int p();
int q(int);
void s();
void t();
void u(short, long);
int v(float, long);
int w();
int ai(char, long, long);
int aj();
int al(long);
void am(short);
int an(double, short, short);
void x();
int y(short);
void ap(float) {
  l(0, 0);
  __builtin_trap();
}
int aq();
__attribute__((__vector_size__(sizeof 0))) float au;
int av(int aw, int ax) {
  if (ax)
  ay:
    __builtin_trap();
  if (au[1])
    __builtin_trap();
  if (aw)
    goto ay;
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
}
int az() {
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  l(0, 0);
  if (__builtin_object_size(as, 0))
    __builtin_trap();
  l(0, 0);
  if (__builtin_object_size(at, 0))
    __builtin_trap();
  l(0, 0);
}
int b;
int ba;
int bb;
void bc(int aw) {
  if (bb)
    goto bd;
  goto be;
bd:
  ad();
  if (e)
    s();
  ba = 3059606 * aw;
  o(ba);
be:
}
__attribute__((noinline, noclone)) int o(int aw) { p() + q(aw); }
int p() {
bg:
  v(0, 0);
  q(0);
  if (g)
    goto bg;
}
int q(int) {
  t();
  u(0, 0);
bh:
  if (ai(0, 0, 0))
    goto bh;
  s();
}
void s() {
  u(0, 0);
  v(f, 5) + w();
}
void t() {
  ai(0, 0, 0);
  u(0, 0);
}
void u(short, long) {
  ai(0, 0, 0);
bh:
  if (ai(0, 0, 0))
    goto bh;
  aj();
}
int v(float, long) {
  ai(0, 0, 0);
  ai(0, 0, 0);
}
int w() {
  am(6);
  ai(0, 0, 0);
  ai(0, 0, 0);
}
__attribute__((noclone)) int ai(char aw, long, long bi) {
  an(0, 0, 0) == aj() - al(0);
  if (aw ? 9 : e)
  bj:
    if (bi)
      if (aw)
        goto bj;
}
int aj() {
  y(0);
  *ae = b;
  if (k)
    if (__builtin_isfinite(ah))
      __builtin_trap();
  ak();
  am(a);
}
int al(long) {
  am(0);
  an(0, 0, 0);
}
void am(short aw) { an(0, 0, aw); }
int an(double, short, short bi) {
  y(0);
  if (h)
    n = *z;
  if (bi << 8 < 7)
    goto bk;
  aq() == av(0, 0);
  goto bl;
bk:
  x();
  ap(0);
bl:
  l(0, 0);
  if (z)
    __builtin_trap();
  if (__builtin_object_size(z, 0))
    l(0, 0);
}
void x() {
  long *bf;
  y(0);
bd:
  *bf = ac - 7;
  if (e)
    goto bd;
}
__attribute__((noclone)) int y(short aw) {
bm:
  if (d)
    __builtin_trap();
  short r = __builtin_ctz(d);
  if (r)
    ap(0);
  if (aw <= 0 ? m : 40268105845986372)
    goto bm;
}
int aq() {
  ar() + az();
  av(3, 0);
  av(3, 0);
  if (ao[5])
    __builtin_trap();
}
int main() {
  bc(1);
  return 0;
}

Reply via email to