华为计算微信公众号
华为计算微博
华为计算今日头条
对于如下代码,gcc 以及bisheng/clang -O0/1 都输出0, 但bisheng -O2/3/s 输出-1.
int printf(const char *, ...); long a; int b; long *c = &a; int(d)(int e, int f) { return e < 0 || e > 7 >> f ? 0 : e << 0; } int main() { b = d(-1, -1); *c = b; printf("%ld\n", a); }
错误如下:
$ gcc-12 a.c && ./a.out 0 $ bisheng/clang -O0 a.c && ./a.out 0 $ bisheng/clang -O1 a.c && ./a.out 0 $ bisheng/clang -O2 a.c && ./a.out warning: Undefined shift transformed to poison value! [-foverflow-shift-alt-behavior] transform overflow shift to predetermined value. warning: Undefined shift transformed to poison value! [-foverflow-shift-alt-behavior] transform overflow shift to predetermined value. -1 $ bisheng/clang -O3 a.c && ./a.out warning: Undefined shift transformed to poison value! [-foverflow-shift-alt-behavior] transform overflow shift to predetermined value. warning: Undefined shift transformed to poison value! [-foverflow-shift-alt-behavior] transform overflow shift to predetermined value. -1
编译器版本:
$ bisheng/clang -v HUAWEI BiSheng Compiler 2.5.0.1 clang version 12.0.0 (clang-4bed3943328c flang-396eaa360043) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /zdata/shaoli/compilers/ccbuilder-compilers 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/9 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11 Candidate multilib: .;@m64 Selected multilib: .;@m64 $
我尝试使用-mllvm -opt-bisect-limit定位bug,结果显示编译结果在经过"Function Integration/Inlining on SCC" pass 后出错。
-mllvm -opt-bisect-limit
Function Integration/Inlining on SCC
本帖最后由 匿名用户 于 2023/11/16 15:51:50 编辑
我要发帖子
对于如下代码,gcc 以及bisheng/clang -O0/1 都输出0, 但bisheng -O2/3/s 输出-1.
int printf(const char *, ...); long a; int b; long *c = &a; int(d)(int e, int f) { return e < 0 || e > 7 >> f ? 0 : e << 0; } int main() { b = d(-1, -1); *c = b; printf("%ld\n", a); }错误如下:
编译器版本:
我尝试使用
-mllvm -opt-bisect-limit定位bug,结果显示编译结果在经过"Function Integration/Inlining on SCC" pass 后出错。