-
Notifications
You must be signed in to change notification settings - Fork 13.4k
[TBAA][DSE] bitfield store is incorrectly optimized out #82586
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
Labels
Comments
Another reproducer: https://godbolt.org/z/Y3bnsMqd7 |
Let me take a look. It seems like clang emits tbaa .struct with overlapping fields. Need to check what exactly is going on |
fhahn
added a commit
that referenced
this issue
Feb 25, 2024
Add test for tbaa.struct metadata creation for copies of a struct with named bitfields. Test for #82586.
fhahn
added a commit
to fhahn/llvm-project
that referenced
this issue
Feb 25, 2024
At the moment, clang generates what I believe are incorrect !tbaa.struct fields for named bitfields. At the moment, the base type size is used for named bifields (e.g. sizeof(int)) instead of the bifield width per field. This results in overalpping fields in !tbaa.struct metadata. This causes incorrect results when extracting individual copied fields from !tbaa.struct as in added in dc85719. This patch fixes that by skipping all bitfields, not only unnamed ones (note that CollectFields has a TODO to support bitfields). As bitfields specify their widths in bits, while !tbaa metadata uses bytes for sizes and offsets, I don't think we would be able to generate correct metadata for them in general. If this understanding is correct, I can also extend the verifier to check that !tbaa.struct fields aren't overlapping. Fixes llvm#82586
fhahn
added a commit
that referenced
this issue
Feb 27, 2024
At the moment, clang generates what I believe are incorrect !tbaa.struct fields for named bitfields. At the moment, the base type size is used for named bifields (e.g. sizeof(int)) instead of the bifield width per field. This results in overalpping fields in !tbaa.struct metadata. This causes incorrect results when extracting individual copied fields from !tbaa.struct as in added in dc85719. This patch fixes that by skipping by combining adjacent bitfields in fields with correct sizes. Fixes #82586
fhahn
added a commit
to fhahn/llvm-project
that referenced
this issue
Mar 1, 2024
Add test for tbaa.struct metadata creation for copies of a struct with named bitfields. Test for llvm#82586. (cherry-picked from 7110147)
fhahn
added a commit
to fhahn/llvm-project
that referenced
this issue
Mar 1, 2024
…82922) At the moment, clang generates what I believe are incorrect !tbaa.struct fields for named bitfields. At the moment, the base type size is used for named bifields (e.g. sizeof(int)) instead of the bifield width per field. This results in overalpping fields in !tbaa.struct metadata. This causes incorrect results when extracting individual copied fields from !tbaa.struct as in added in dc85719. This patch fixes that by skipping by combining adjacent bitfields in fields with correct sizes. Fixes llvm#82586 (cherry-picked from d2a9df2)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reproducer: https://godbolt.org/z/jKrGW5jEh
x->f2 = 3
is incorrectly eliminated byDSEPass
.This miscompilation is caused by recent commit #81313.
The text was updated successfully, but these errors were encountered: