Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opt generates wrong code with "-passes=dse,newgvn" #70421

Open
Bazoka13 opened this issue Oct 27, 2023 · 2 comments
Open

opt generates wrong code with "-passes=dse,newgvn" #70421

Bazoka13 opened this issue Oct 27, 2023 · 2 comments

Comments

@Bazoka13
Copy link


OS and Platform:
Ubuntu 20.04.4 LTS


clang version:
$ clang -v
clang version 17.0.3
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/llvm-releases/llvm-17.0.3/build/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/9
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@MX32
Selected multilib: .;@m64


Command Lines:

clang -O3 -mllvm -disable-llvm-optzns -c -emit-llvm a.c -o a.bc
opt -passes=dse,newgvn a.bc -o a.opt.bc
clang a.opt.bc -o a.out
 ./a.out
4
opt a.bc -o a0.opt.bc
clang a0.opt.bc -o a0.out
./a0.out 
-17

Source Code:

#include<stdio.h>
struct {
  int a;
} b;
short c;
unsigned int d() {
  int e[2][3][9] = {};
  unsigned char f;
  for (c = -17; c < 0; c = 4) {
    int g;
    for (; b.a >= 0;)
      for (f = 0;;) {
        int h;
        return e[f][f][0];
      }
  }
  return e[0][0][1];
}
int main() {
  d();
  printf("%d\n", c);
}
@knightXun
Copy link
Contributor

I want to track this issue

@alinas
Copy link
Contributor

alinas commented Oct 27, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants