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

wrong code at -Os and above on x86_64-linux-gnu #49685

Closed
zhendongsu opened this issue May 14, 2021 · 4 comments
Closed

wrong code at -Os and above on x86_64-linux-gnu #49685

zhendongsu opened this issue May 14, 2021 · 4 comments
Labels
bugzilla Issues migrated from bugzilla

Comments

@zhendongsu
Copy link

Bugzilla Link 50341
Resolution FIXED
Resolved on May 14, 2021 11:32
Version trunk
OS All
CC @rotateright

Extended Description

It seems to be a recent regression and might be related to #49668 .

[618] % clangtk -v
clang version 13.0.0 (https://github.com/llvm/llvm-project.git 4789fc7)
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/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/7.5.0
Candidate multilib: .;@m64
Candidate multilib: 32;@m32
Candidate multilib: x32;@MX32
Selected multilib: .;@m64
[619] %
[619] % clangtk -O1 small.c; ./a.out
-4
[620] % clangtk -Os small.c
[621] % ./a.out
-2
[622] %
[622] % cat small.c
int printf (const char *, ...);
char a, f;
int b, d;
static int *c = &b;
unsigned char g(unsigned char h, int i) { return h << i; }
void j(int **h) { j(&c); }
int main() {
*c = 0;
d = b | -2;
f = g(d, a == 0);
printf("%d\n", f);
return 0;
}

@rotateright
Copy link
Contributor

The bug is in instcombine. Still stepping through, but I suspect it was caused by:
https://reviews.llvm.org/rG1b24f35f843c

@rotateright
Copy link
Contributor

*** Bug #49668 has been marked as a duplicate of this bug. ***

@rotateright
Copy link
Contributor

Thanks for finding the bug and easy reproducer!

Should be fixed with:
https://reviews.llvm.org/rGe82db87fb102

@zhendongsu
Copy link
Author

Thanks for finding the bug and easy reproducer!

Should be fixed with:
https://reviews.llvm.org/rGe82db87fb102

Thanks for the fix, Sanjay!

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 11, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

2 participants