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

[NewGVN] wrong code at Os and above with -mllvm -enable-newgvn

Open zhendongsu opened this issue 3 years ago • 4 comments

It appears to be a recent regression as it does not reproduce with 16.0.0.

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

% clangtk -v
clang version 17.0.0 (https://github.com/llvm/llvm-project.git 09d6ee765780837d5156ac81f968465bdcec73ba)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /local/suz-local/opfuzz/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
% 
% clangtk -O3 small.c; ./a.out
% clangtk -O3 -mllvm -enable-newgvn small.c
% timeout -s 9 5 ./a.out
Killed
% 
% cat small.c
int a = 1, b, c, d;
static int *e;
int main() {
  int f;
  if (!d) {
    f = 1 ^ a;
    if (b) {
      if (f) {
        int g;
      } else
        *e = 0;
    }
  }
  if (~f | c)
    while (f)
      ;
  return 0;
}

zhendongsu avatar Jun 15 '23 21:06 zhendongsu

git bisect points to 2ca21e8775dd16189bb4c00c3f9553f17578a63c.

gandhi56 avatar Jul 01 '23 05:07 gandhi56

https://reviews.llvm.org/D154307

gandhi56 avatar Jul 02 '23 20:07 gandhi56

The fix is up for review https://github.com/llvm/llvm-project/pull/66314

kmitropoulou avatar Sep 16 '23 03:09 kmitropoulou

The patch was committed.

kmitropoulou avatar Sep 18 '23 19:09 kmitropoulou