Use the TBAA info of the omnipotent char for these objects.
Details
- Reviewers
rjmccall eli.friedman • dberlin hfinkel rsmith - Commits
- rG5960a57ef79e: [CodeGen] Pessimize aliasing for member unions (and may-alias) objects
rC303851: [CodeGen] Pessimize aliasing for member unions (and may-alias) objects
rL303851: [CodeGen] Pessimize aliasing for member unions (and may-alias) objects
Diff Detail
- Repository
- rL LLVM
Event Timeline
The diff is the same as before, the change is in the subscribers: from llvm-commits to cfe-commits.
Previously, the variable mayAlias in EmitLValueForField could have been false even if the base LValue had may-alias flag set. Make sure that mayAlias reflects the base aliasing.
This fixed the C++ testcase and it's now included in the patch.
test/CodeGen/union-tbaa1.c | ||
---|---|---|
45 | What needs to be checked exactly? The offset will be 0, do you want to check for that? |
test/CodeGen/union-tbaa1.c | ||
---|---|---|
45 | Yes, because if it's not zero, this won't have the desired effect. |
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
1436 | Hmm. Should we be constructing a struct-path TBAA at all if the base may alias, as opposed to just using 'char'? |
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
1436 | I did that and got a verifier error: "Old-style TBAA is no longer allowed, use struct-path TBAA instead. fatal error: error in backend: Broken function found, compilation aborted!" |
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
1436 | Oh, I haven't been paying enough attention to LLVM's TBAA changes. It looks like they've canonicalized on always using the struct-access-style TBAA metadata, which is fine; the point is that we should be using whatever tag we would use for dereferencing a simple char*, which I believe just means passing true for ConvertTypeToTag to DecorateInstructionWithTBAA . |
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
1436 | With that change I'm getting another error: Access type node must be a valid scalar type store <4 x double> %call2, <4 x double>* %b, align 32, !tbaa !8 !8 = !{!9, !9, i64 0} !9 = !{!4, !4, i64 0} fatal error: error in backend: Broken function found, compilation aborted! |
lib/CodeGen/CGExpr.cpp | ||
---|---|---|
1436 | Sorry, I see now that what I said was unclear. If you do this, you need to pass the result of getTBAAInfo(CharTy) down as the argument to DecorateInstructionWithTBAA instead of building of a TBAA struct tag. |
Pass char TBAA directly to DecorateInstructionWithTBAA and pass true for ConvertTypeToTag in such cases.
Hmm. Should we be constructing a struct-path TBAA at all if the base may alias, as opposed to just using 'char'?