From a5986b9e91be95771a034b5efe400e99149f919c Mon Sep 17 00:00:00 2001 From: Hal Finkel Date: Sun, 3 Dec 2017 03:10:13 +0000 Subject: 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 --- clang/lib/CodeGen/CGExpr.cpp | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) (limited to 'clang/lib/CodeGen/CGExpr.cpp') 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() || 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(); -- cgit v1.2.3