-
Notifications
You must be signed in to change notification settings - Fork 146
inconsistency alignment of store instructions #1204
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
Comments
Interesting. |
Indeed, another interesting example to showcase this: struct Foo {
short a;
short b;
short c;
short d;
int e; // Make the struct 4-byte aligned
};
void test(Foo *ptr) {
ptr->a = 1; // align 4
ptr->b = 2; // align 2
ptr->c = 3; // align 4
ptr->d = 4; // align 2
} The alignments original clang emitted for the 4 stores in |
Yup, and it's also able to do clever things like (https://godbolt.org/z/hP8nbhara):
|
This change corrects the alignment of store operations and fixes a related problem with calculation of member offsets (we weren't accounting for the alignment of the field whose offset we were calculating. Many tests are affected by this, but most just needed a wildcard match to ignore the explicit alignment which wasn't present before. In cases where I updated a check for a specific alignment value, I compared against classic codegen to verify that we are now producing the same alignment. Two new tests are added align-store.c and alignment.cpp. The second of these partially copies a test of the same name from clang/test/CodeGen. It's testing globals and isn't directly related to the code changes here, but we didn't seem to have a test for this. I put the store alignment tests in a different file because inconsistency between CIR and LLVM IR in placement of globals would have made a combined test difficult to follow. This addresses #1204
Fixed by #1637 |
I'm testing #1076 with
clang/test/CodeGen/tbaa.cpp
.and I have noticed an inconsistency in the alignment of store instructions between the LLVM IR generated by
clang
and the one produced byClangIR
.Here is a simplified example that demonstrates the difference:
LLVM IR Generated by Clang
The following is the LLVM IR output when compiled with
clang
:LLVM IR Generated by ClangIR
In contrast, the LLVM IR produced by
ClangIR
is as follows:Comparison
The significant difference lies in this line:
store i16 4, ptr %f16, align 4
store i16 4, ptr %10, align 2
The text was updated successfully, but these errors were encountered: