毕昇3.1.0 编译Bug #2
收藏回复举报
毕昇3.1.0 编译Bug #2
t('forum.solved') 已解决
发表于2023-11-29 18:43:52
0 查看

毕昇3.1.0的opt在通过优化"-passes=dse,newgvn"编译特定代码时会生成错误代码

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 a.opt.bc
clang a.opt.bc -o a.out
./a.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);
  return 0;
}

我要发帖子