summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorIvan A. Kosarev <ikosarev@accesssoftek.com>2017-12-18 20:05:20 +0000
committerIvan A. Kosarev <ikosarev@accesssoftek.com>2017-12-18 20:05:20 +0000
commita80c79b5bfb7f8632571a2631d9883933600be07 (patch)
treefa57fcd8b2add8a8e9d2f1f1d84552bed8c33173 /llvm/lib/Analysis
parent915897e21b1286d396748cf6bf47cebdae32f41e (diff)
downloadbcm5719-llvm-a80c79b5bfb7f8632571a2631d9883933600be07.tar.gz
bcm5719-llvm-a80c79b5bfb7f8632571a2631d9883933600be07.zip
[Analysis] Generate more precise TBAA tags when one access encloses the other
There are cases when two tags with different base types denote accesses to the same direct or indirect member of a structure type. Currently, merging of such tags results in a tag that represents an access to an object that has the type of that member. This patch changes this so that if one of the accesses encloses the other, then the generic tag is the one of the enclosed access. Differential Revision: https://reviews.llvm.org/D39557 llvm-svn: 321019
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
index c9ed026a1e3..173db399b9d 100644
--- a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
@@ -544,21 +544,32 @@ static bool matchAccessTags(const MDNode *A, const MDNode *B,
TBAAStructTagNode TagA(A), TagB(B);
const MDNode *CommonType = getLeastCommonType(TagA.getAccessType(),
TagB.getAccessType());
- if (GenericTag)
- *GenericTag = createAccessTag(CommonType);
// TODO: We need to check if AccessType of TagA encloses AccessType of
// TagB to support aggregate AccessType. If yes, return true.
// Climb the type DAG from base type of A to see if we reach base type of B.
uint64_t OffsetA;
- if (findAccessType(TagA, TagB.getBaseType(), OffsetA))
- return OffsetA == TagB.getOffset();
+ if (findAccessType(TagA, TagB.getBaseType(), OffsetA)) {
+ bool SameMemberAccess = OffsetA == TagB.getOffset();
+ if (GenericTag)
+ *GenericTag = SameMemberAccess ? TagB.getNode() :
+ createAccessTag(CommonType);
+ return SameMemberAccess;
+ }
// Climb the type DAG from base type of B to see if we reach base type of A.
uint64_t OffsetB;
- if (findAccessType(TagB, TagA.getBaseType(), OffsetB))
- return OffsetB == TagA.getOffset();
+ if (findAccessType(TagB, TagA.getBaseType(), OffsetB)) {
+ bool SameMemberAccess = OffsetB == TagA.getOffset();
+ if (GenericTag)
+ *GenericTag = SameMemberAccess ? TagA.getNode() :
+ createAccessTag(CommonType);
+ return SameMemberAccess;
+ }
+
+ if (GenericTag)
+ *GenericTag = createAccessTag(CommonType);
// If the final access types have different roots, they're part of different
// potentially unrelated type systems, so we must be conservative.
OpenPOWER on IntegriCloud