[llvm-commits] [llvm] r113892 - /llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp

Dan Gohman gohman at apple.com
Tue Sep 14 16:28:12 PDT 2010


Author: djg
Date: Tue Sep 14 18:28:12 2010
New Revision: 113892

URL: http://llvm.org/viewvc/llvm-project?rev=113892&view=rev
Log:
Convert TBAA to use the new TBAATag field of AliasAnalysis::Location.

Modified:
    llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp

Modified: llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp?rev=113892&r1=113891&r2=113892&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/TypeBasedAliasAnalysis.cpp Tue Sep 14 18:28:12 2010
@@ -44,7 +44,7 @@
 
   public:
     TBAANode() : Node(0) {}
-    explicit TBAANode(MDNode *N) : Node(N) {}
+    explicit TBAANode(const MDNode *N) : Node(N) {}
 
     /// getNode - Get the MDNode for this TBAANode.
     const MDNode *getNode() const { return Node; }
@@ -119,21 +119,11 @@
 AliasAnalysis::AliasResult
 TypeBasedAliasAnalysis::alias(const Location &LocA,
                               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
   // be conservative.
-  MDNode *AM =
-    AI->getMetadata(AI->getParent()->getParent()->getParent()
-                      ->getMDKindID("tbaa"));
+  const MDNode *AM = LocA.TBAATag;
   if (!AM) return MayAlias;
-  MDNode *BM =
-    BI->getMetadata(BI->getParent()->getParent()->getParent()
-                      ->getMDKindID("tbaa"));
+  const MDNode *BM = LocB.TBAATag;
   if (!BM) return MayAlias;
 
   // Keep track of the root node for A and B.
@@ -175,13 +165,7 @@
 }
 
 bool TypeBasedAliasAnalysis::pointsToConstantMemory(const Location &Loc) {
-  // Currently, metadata can only be attached to Instructions.
-  const Instruction *I = dyn_cast<Instruction>(Loc.Ptr);
-  if (!I) return false;
-
-  MDNode *M =
-    I->getMetadata(I->getParent()->getParent()->getParent()
-                    ->getMDKindID("tbaa"));
+  const MDNode *M = Loc.TBAATag;
   if (!M) return false;
 
   // If this is an "immutable" type, we can assume the pointer is pointing





More information about the llvm-commits mailing list