-
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
Clang initialization code generation can be improved #651
Comments
Here's a testcase in the regression suite: |
Here's another testcase: struct T { int A, B; }; int test1(int x) { int test2() { int test3(int x) { |
Here is the example from comment #1: // RUN: %llvmgcc -xc %s -c -o - | llvm-dis | grep llvm.memset |
From comment #1, we memset the first two arrays. However, we use a bunch of SSE instructions to initialize the "Pairs" variable:
|
We don't care about llvm-gcc anymore, so stealing this for Clang. After r120645, clang now generates the right code for the second Arr testcase in Comment 0, and also handles hte Pairs example nicely from Comment #0. It handles the examples in comment #2, and the "str" case from comment 3. The example in comment 1 doesn't exist anymore. The one remaining issue is that it does not handle this well from comment #0: int foo(int X) { |
Finished off in r120692. We now generate a memset + 1 store. |
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
Though we are generating better code for GCC CONSTRUCTOR nodes (See Bug 275), we
still aren't doing as well as we should do. In particular, we handle cases like
this poorly:
int foo(int X) {
int Arr[100] = { X }; // Should use memset
int Arr[10000] = { 1 }; // Should use memset
// Should memcpy the whole thing
struct { int A, B } Pairs[10] = { {1, 2 }, { 0, 0 } };
}
... While the first ones could be addressed right now, the last one requires a
rewrite of how we handle constructors, which is needed to fix several code
correctness bugs anyway. This bug is just a tracker for when this happens.
-Chris
The text was updated successfully, but these errors were encountered: