summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorSanjoy Das <sanjoy@playingwithpointers.com>2016-11-08 20:46:01 +0000
committerSanjoy Das <sanjoy@playingwithpointers.com>2016-11-08 20:46:01 +0000
commit2582e690b7088e938d33dd5e3d271f92d44ba16c (patch)
tree8882021c2d37be7a3073b9d34c380994c2dccc1c /llvm/lib
parentd092107b0e07b1861e541e5f21b342a74218ccb9 (diff)
downloadbcm5719-llvm-2582e690b7088e938d33dd5e3d271f92d44ba16c.tar.gz
bcm5719-llvm-2582e690b7088e938d33dd5e3d271f92d44ba16c.zip
[TBAA] Drop support for "old style" scalar TBAA tags
Summary: We've had support for auto upgrading old style scalar TBAA access metadata tags into the "new" struct path aware TBAA metadata for 3 years now. The only way to actually generate old style TBAA was explicitly through the IRBuilder API. I think this is a good time for dropping support for old style scalar TBAA. I'm not removing support for textual or bitcode upgrade -- if you have IR with the old style scalar TBAA tags that go through the AsmParser orf the bitcode parser before LLVM sees them, they will keep working as usual. Note: %val = load i32, i32* %ptr, !tbaa !N !N = < scalar tbaa node > is equivalent to %val = load i32, i32* %ptr, !tbaa !M !N = < scalar tbaa node > !M = !{!N, !N, 0} Reviewers: manmanren, chandlerc, sunfish Subscribers: mcrosier, llvm-commits, mgorny Differential Revision: https://reviews.llvm.org/D26229 llvm-svn: 286291
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp67
-rw-r--r--llvm/lib/IR/Verifier.cpp13
2 files changed, 23 insertions, 57 deletions
diff --git a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
index 1baa095a243..e5ef734aab5 100644
--- a/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
+++ b/llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp
@@ -417,15 +417,14 @@ MDNode *MDNode::getMostGenericTBAA(MDNode *A, MDNode *B) {
return A;
// For struct-path aware TBAA, we use the access type of the tag.
- bool StructPath = isStructPathTBAA(A) && isStructPathTBAA(B);
- if (StructPath) {
- A = cast_or_null<MDNode>(MutableTBAAStructTagNode(A).getAccessType());
- if (!A)
- return nullptr;
- B = cast_or_null<MDNode>(MutableTBAAStructTagNode(B).getAccessType());
- if (!B)
- return nullptr;
- }
+ assert(isStructPathTBAA(A) && isStructPathTBAA(B) &&
+ "Auto upgrade should have taken care of this!");
+ A = cast_or_null<MDNode>(MutableTBAAStructTagNode(A).getAccessType());
+ if (!A)
+ return nullptr;
+ B = cast_or_null<MDNode>(MutableTBAAStructTagNode(B).getAccessType());
+ if (!B)
+ return nullptr;
SmallSetVector<MDNode *, 4> PathA;
MutableTBAANode TA(A);
@@ -457,8 +456,6 @@ MDNode *MDNode::getMostGenericTBAA(MDNode *A, MDNode *B) {
--IA;
--IB;
}
- if (!StructPath)
- return Ret;
if (!Ret)
return nullptr;
@@ -492,52 +489,8 @@ void Instruction::getAAMetadata(AAMDNodes &N, bool Merge) const {
/// Aliases - Test whether the type represented by A may alias the
/// type represented by B.
bool TypeBasedAAResult::Aliases(const MDNode *A, const MDNode *B) const {
- // Make sure that both MDNodes are struct-path aware.
- if (isStructPathTBAA(A) && isStructPathTBAA(B))
- return PathAliases(A, B);
-
- // Keep track of the root node for A and B.
- TBAANode RootA, RootB;
-
- // Climb the tree from A to see if we reach B.
- for (TBAANode T(A);;) {
- if (T.getNode() == B)
- // B is an ancestor of A.
- return true;
-
- RootA = T;
- T = T.getParent();
- if (!T.getNode())
- break;
- }
-
- // Climb the tree from B to see if we reach A.
- for (TBAANode T(B);;) {
- if (T.getNode() == A)
- // A is an ancestor of B.
- return true;
-
- RootB = T;
- T = T.getParent();
- if (!T.getNode())
- break;
- }
-
- // Neither node is an ancestor of the other.
-
- // If they have different roots, they're part of different potentially
- // unrelated type systems, so we must be conservative.
- if (RootA.getNode() != RootB.getNode())
- return true;
-
- // If they have the same root, then we've proved there's no alias.
- return false;
-}
-
-/// Test whether the struct-path tag represented by A may alias the
-/// struct-path tag represented by B.
-bool TypeBasedAAResult::PathAliases(const MDNode *A, const MDNode *B) const {
- // Verify that both input nodes are struct-path aware.
+ // Verify that both input nodes are struct-path aware. Auto-upgrade should
+ // have taken care of this.
assert(isStructPathTBAA(A) && "MDNode A is not struct-path aware.");
assert(isStructPathTBAA(B) && "MDNode B is not struct-path aware.");
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index a8a1df3e8b4..31a181e8db4 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -391,6 +391,7 @@ private:
void visitBasicBlock(BasicBlock &BB);
void visitRangeMetadata(Instruction& I, MDNode* Range, Type* Ty);
void visitDereferenceableMetadata(Instruction& I, MDNode* MD);
+ void visitTBAAMetadata(Instruction &I, MDNode *MD);
template <class Ty> bool isValidMetadataArray(const MDTuple &N);
#define HANDLE_SPECIALIZED_MDNODE_LEAF(CLASS) void visit##CLASS(const CLASS &N);
@@ -3658,6 +3659,15 @@ void Verifier::visitDereferenceableMetadata(Instruction& I, MDNode* MD) {
"dereferenceable_or_null metadata value must be an i64!", &I);
}
+void Verifier::visitTBAAMetadata(Instruction &I, MDNode *MD) {
+ bool IsStructPathTBAA =
+ isa<MDNode>(MD->getOperand(0)) && MD->getNumOperands() >= 3;
+
+ Assert(IsStructPathTBAA,
+ "Old-style TBAA is no longer allowed, use struct-path TBAA instead",
+ &I);
+}
+
/// verifyInstruction - Verify that an instruction is well formed.
///
void Verifier::visitInstruction(Instruction &I) {
@@ -3793,6 +3803,9 @@ void Verifier::visitInstruction(Instruction &I) {
if (MDNode *MD = I.getMetadata(LLVMContext::MD_dereferenceable_or_null))
visitDereferenceableMetadata(I, MD);
+ if (MDNode *MD = I.getMetadata(LLVMContext::MD_tbaa))
+ visitTBAAMetadata(I, MD);
+
if (MDNode *AlignMD = I.getMetadata(LLVMContext::MD_align)) {
Assert(I.getType()->isPointerTy(), "align applies only to pointer types",
&I);
OpenPOWER on IntegriCloud