-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
[llvmgcc] Variable length array indexing miscompiled #670
Comments
Here's another horrible testcase with the same issue: int sub1 (int i, int j) { if (j == 2) { int main() { |
This patch: Fixes this testcase (test/Regression/CFrontend/2004-05-07-VarArrays.c): int foo(int len, char arr[][len], int X) { The second testcase attached to this bug is actually a bug in the non-LLVM -Chris |
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`, `fmod`, and `pow`. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This PR tries to correct this mistake. It makes all CIR FP intrinsic ops lower to their corresponding LLVM intrinsics (`fmod` is a special case and it is lowered to the `frem` LLVM instruction).
LLVM lowering for the following operations is introduced in llvm#616 and llvm#651: `cos`, `exp`, `exp2`, `log`, `log10`, `log2`, `sin`, `sqrt`, `fmod`, and `pow`. However, they are not lowered to their corresponding LLVM intrinsics; instead they are transformed to libc calls during lowering prepare. This does not match the upstream behavior. This PR tries to correct this mistake. It makes all CIR FP intrinsic ops lower to their corresponding LLVM intrinsics (`fmod` is a special case and it is lowered to the `frem` LLVM instruction).
Extended Description
It looks like we are miscompiling indexes through C99 VLA's in some cases. File
this into the "wow, I didn't know you could do that" catagory. :)
Testcase:
int foo(int len, char arr[][len], int X) {
return arr[X][0];
}
The correct addressing arithmetic to generate is "arr + X*len", which we don't
do in this case.
-Chris
The text was updated successfully, but these errors were encountered: