diff options
author | Hal Finkel <hfinkel@anl.gov> | 2017-09-03 17:18:25 +0000 |
---|---|---|
committer | Hal Finkel <hfinkel@anl.gov> | 2017-09-03 17:18:25 +0000 |
commit | 7ede89db2c39be7ae220fdb4d1d5c9325a6c776a (patch) | |
tree | 7700cf89aec7c4eefcb35dcddfb86e62d75d6118 /lib/CodeGen/CGExpr.cpp | |
parent | cfe18e70e79cd46a6bba3183e7ead0d2653af188 (diff) |
[CodeGen] Treat all vector fields as mayalias
Because it is common to treat vector types as an array of their elements, or
even some other type that's not the element type, and thus index into them, we
can't use struct-path TBAA for these accesses. Even though we already treat all
vector types as equivalent to 'char', we were using field-offset information
for them with TBAA, and this renders undefined the intra-value indexing we
intend to allow. Note that, although 'char' is universally aliasing, with path
TBAA, we can still differentiate between access to s.a and s.b in
struct { char a, b; } s;. We can't use this capability as-is for vector types.
Fixes PR33967.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@312447 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index bff3fcf6db..2b0086d22a 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -3665,8 +3665,9 @@ LValue CodeGenFunction::EmitLValueForField(LValue base, getFieldAlignmentSource(BaseInfo.getAlignmentSource()); LValueBaseInfo FieldBaseInfo(fieldAlignSource, BaseInfo.getMayAlias()); + QualType type = field->getType(); const RecordDecl *rec = field->getParent(); - if (rec->isUnion() || rec->hasAttr<MayAliasAttr>()) + if (rec->isUnion() || rec->hasAttr<MayAliasAttr>() || type->isVectorType()) FieldBaseInfo.setMayAlias(true); bool mayAlias = FieldBaseInfo.getMayAlias(); @@ -3691,7 +3692,6 @@ LValue CodeGenFunction::EmitLValueForField(LValue base, return LValue::MakeBitfield(Addr, Info, fieldType, FieldBaseInfo); } - QualType type = field->getType(); Address addr = base.getAddress(); unsigned cvr = base.getVRQualifiers(); bool TBAAPath = CGM.getCodeGenOpts().StructPathTBAA; |