Convert TBAA to use the new TBAATag field of AliasAnalysis::Location.

llvm-svn: 113892
This commit is contained in:
Dan Gohman 2010-09-14 23:28:12 +00:00
parent 092b6fb187
commit e0386dbef1
1 changed files with 4 additions and 20 deletions

View File

@ -44,7 +44,7 @@ namespace {
public: public:
TBAANode() : Node(0) {} TBAANode() : Node(0) {}
explicit TBAANode(MDNode *N) : Node(N) {} explicit TBAANode(const MDNode *N) : Node(N) {}
/// getNode - Get the MDNode for this TBAANode. /// getNode - Get the MDNode for this TBAANode.
const MDNode *getNode() const { return Node; } const MDNode *getNode() const { return Node; }
@ -119,21 +119,11 @@ TypeBasedAliasAnalysis::getAnalysisUsage(AnalysisUsage &AU) const {
AliasAnalysis::AliasResult AliasAnalysis::AliasResult
TypeBasedAliasAnalysis::alias(const Location &LocA, TypeBasedAliasAnalysis::alias(const Location &LocA,
const Location &LocB) { const Location &LocB) {
// Currently, metadata can only be attached to Instructions.
const Instruction *AI = dyn_cast<Instruction>(LocA.Ptr);
if (!AI) return MayAlias;
const Instruction *BI = dyn_cast<Instruction>(LocB.Ptr);
if (!BI) return MayAlias;
// Get the attached MDNodes. If either value lacks a tbaa MDNode, we must // Get the attached MDNodes. If either value lacks a tbaa MDNode, we must
// be conservative. // be conservative.
MDNode *AM = const MDNode *AM = LocA.TBAATag;
AI->getMetadata(AI->getParent()->getParent()->getParent()
->getMDKindID("tbaa"));
if (!AM) return MayAlias; if (!AM) return MayAlias;
MDNode *BM = const MDNode *BM = LocB.TBAATag;
BI->getMetadata(BI->getParent()->getParent()->getParent()
->getMDKindID("tbaa"));
if (!BM) return MayAlias; if (!BM) return MayAlias;
// Keep track of the root node for A and B. // Keep track of the root node for A and B.
@ -175,13 +165,7 @@ TypeBasedAliasAnalysis::alias(const Location &LocA,
} }
bool TypeBasedAliasAnalysis::pointsToConstantMemory(const Location &Loc) { bool TypeBasedAliasAnalysis::pointsToConstantMemory(const Location &Loc) {
// Currently, metadata can only be attached to Instructions. const MDNode *M = Loc.TBAATag;
const Instruction *I = dyn_cast<Instruction>(Loc.Ptr);
if (!I) return false;
MDNode *M =
I->getMetadata(I->getParent()->getParent()->getParent()
->getMDKindID("tbaa"));
if (!M) return false; if (!M) return false;
// If this is an "immutable" type, we can assume the pointer is pointing // If this is an "immutable" type, we can assume the pointer is pointing