summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2017-12-03 03:10:13 +0000
committerHal Finkel <hfinkel@anl.gov>2017-12-03 03:10:13 +0000
commita5986b9e91be95771a034b5efe400e99149f919c (patch)
tree6661a2270eb6f0e6bec286a186f18b382c23349e /clang/lib/CodeGen/CGExpr.cpp
parentf3470e1ed4f6322711f6fc059b834d2ce0094c2b (diff)
downloadbcm5719-llvm-a5986b9e91be95771a034b5efe400e99149f919c.tar.gz
bcm5719-llvm-a5986b9e91be95771a034b5efe400e99149f919c.zip
Revert "[CodeGen] Add initial support for union members in TBAA"
This reverts commit r319413. See PR35503. We can't use "union member" as the access type here like this. llvm-svn: 319629
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp33
1 files changed, 13 insertions, 20 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 50d116ec7d8..88116f7d810 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3723,6 +3723,9 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
if (base.getTBAAInfo().isMayAlias() ||
rec->hasAttr<MayAliasAttr>() || FieldType->isVectorType()) {
FieldTBAAInfo = TBAAAccessInfo::getMayAliasInfo();
+ } else if (rec->isUnion()) {
+ // TODO: Support TBAA for unions.
+ FieldTBAAInfo = TBAAAccessInfo::getMayAliasInfo();
} else {
// If no base type been assigned for the base access, then try to generate
// one for this base lvalue.
@@ -3733,26 +3736,16 @@ LValue CodeGenFunction::EmitLValueForField(LValue base,
"Nonzero offset for an access with no base type!");
}
- // All union members are encoded to be of the same special type.
- if (FieldTBAAInfo.BaseType && rec->isUnion())
- FieldTBAAInfo = TBAAAccessInfo::getUnionMemberInfo(FieldTBAAInfo.BaseType,
- FieldTBAAInfo.Offset,
- FieldTBAAInfo.Size);
-
- // For now we describe accesses to direct and indirect union members as if
- // they were at the offset of their outermost enclosing union.
- if (!FieldTBAAInfo.isUnionMember()) {
- // Adjust offset to be relative to the base type.
- const ASTRecordLayout &Layout =
- getContext().getASTRecordLayout(field->getParent());
- unsigned CharWidth = getContext().getCharWidth();
- if (FieldTBAAInfo.BaseType)
- FieldTBAAInfo.Offset +=
- Layout.getFieldOffset(field->getFieldIndex()) / CharWidth;
-
- // Update the final access type.
- FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType);
- }
+ // Adjust offset to be relative to the base type.
+ const ASTRecordLayout &Layout =
+ getContext().getASTRecordLayout(field->getParent());
+ unsigned CharWidth = getContext().getCharWidth();
+ if (FieldTBAAInfo.BaseType)
+ FieldTBAAInfo.Offset +=
+ Layout.getFieldOffset(field->getFieldIndex()) / CharWidth;
+
+ // Update the final access type.
+ FieldTBAAInfo.AccessType = CGM.getTBAATypeInfo(FieldType);
}
Address addr = base.getAddress();
OpenPOWER on IntegriCloud