llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

clang crashes at -O3 on x86_64-linux-gnu: fatal error: error in backend: Instruction Combining seems stuck in an infinite loop after 100 iterations.

Open zhendongsu opened this issue 2 years ago • 0 comments

It appears to be a recent regression.

Compiler Explorer: https://godbolt.org/z/TEqGhcT7r

[507] % clangtk -v
clang version 16.0.0 (https://github.com/llvm/llvm-project.git de6fd169715764f0401d8580b64c11fda45101e1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/10
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
[508] % 
[508] % clangtk -O2 small.c; ./a.out
[509] % 
[509] % clangtk -O3 small.c
fatal error: error in backend: Instruction Combining seems stuck in an infinite loop after 100 iterations.
clang-16: error: clang frontend command failed with exit code 70 (use -v to see invocation)
clang version 16.0.0 (https://github.com/llvm/llvm-project.git de6fd169715764f0401d8580b64c11fda45101e1)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
clang-16: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-16: note: diagnostic msg: /tmp/small-3fdae0.c
clang-16: note: diagnostic msg: /tmp/small-3fdae0.sh
clang-16: note: diagnostic msg: 

********************
[510] % cat small.c
int a, b, c, d, e;
int f() { return a; }
void g() {
  int *h = &b, *i = &b, *j = &b;
  while (a) {
    d = 1;
    break;
  }
  *h ^= e = 2;
  for (; e; e--) {
    c = 0;
    for (; c <= 50; c++) {
      if (*j)
        continue;
      *i ^= f();
    }
  }
}
int main() {
  g();
  return 0;
}

zhendongsu avatar Aug 16 '22 23:08 zhendongsu