Make this pass registration static as well.
[oota-llvm.git] / lib / Analysis / BasicAliasAnalysis.cpp
index 0ca8d5a38d4417de51e133df0388bdaa022433aa..b6072fdf876ede9d02bbdfe5a3a5fb7f7e5f5eac 100644 (file)
@@ -22,6 +22,7 @@
 #include "llvm/Instructions.h"
 #include "llvm/Pass.h"
 #include "llvm/Target/TargetData.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/GetElementPtrTypeIterator.h"
 #include "llvm/Support/ManagedStatic.h"
@@ -35,6 +36,10 @@ namespace {
   /// such it doesn't follow many of the rules that other alias analyses must.
   ///
   struct VISIBILITY_HIDDEN NoAA : public ImmutablePass, public AliasAnalysis {
+    static char ID; // Class identification, replacement for typeinfo
+    NoAA() : ImmutablePass((intptr_t)&ID) {}
+    explicit NoAA(intptr_t PID) : ImmutablePass(PID) { }
+
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.addRequired<TargetData>();
     }
@@ -73,6 +78,7 @@ namespace {
   };
 
   // Register this pass...
+  char NoAA::ID = 0;
   RegisterPass<NoAA>
   U("no-aa", "No Alias Analysis (always returns 'may' alias)");
 
@@ -87,6 +93,8 @@ namespace {
   /// Because it doesn't chain to a previous alias analysis (like -no-aa), it
   /// derives from the NoAA class.
   struct VISIBILITY_HIDDEN BasicAliasAnalysis : public NoAA {
+    static char ID; // Class identification, replacement for typeinfo
+    BasicAliasAnalysis() : NoAA((intptr_t)&ID) { }
     AliasResult alias(const Value *V1, unsigned V1Size,
                       const Value *V2, unsigned V2Size);
 
@@ -118,6 +126,7 @@ namespace {
   };
 
   // Register this pass...
+  char BasicAliasAnalysis::ID = 0;
   RegisterPass<BasicAliasAnalysis>
   X("basicaa", "Basic Alias Analysis (default AA impl)");
 
@@ -160,7 +169,8 @@ static const User *isGEP(const Value *V) {
   return 0;
 }
 
-static const Value *GetGEPOperands(const Value *V, std::vector<Value*> &GEPOps){
+static const Value *GetGEPOperands(const Value *V, 
+                                   SmallVector<Value*, 16> &GEPOps){
   assert(GEPOps.empty() && "Expect empty list to populate!");
   GEPOps.insert(GEPOps.end(), cast<User>(V)->op_begin()+1,
                 cast<User>(V)->op_end());
@@ -369,7 +379,7 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size,
       // non-aliasing.
 
       // Collect all of the chained GEP operands together into one simple place
-      std::vector<Value*> GEP1Ops, GEP2Ops;
+      SmallVector<Value*, 16> GEP1Ops, GEP2Ops;
       BasePtr1 = GetGEPOperands(V1, GEP1Ops);
       BasePtr2 = GetGEPOperands(V2, GEP2Ops);
 
@@ -398,7 +408,7 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size,
 
   if (V1Size != ~0U && V2Size != ~0U)
     if (isGEP(V1)) {
-      std::vector<Value*> GEPOperands;
+      SmallVector<Value*, 16> GEPOperands;
       const Value *BasePtr = GetGEPOperands(V1, GEPOperands);
 
       AliasResult R = alias(BasePtr, V1Size, V2, V2Size);
@@ -618,7 +628,7 @@ BasicAliasAnalysis::CheckGEPInstructions(
     if (NumGEP1Ops > MinOperands) {
       for (unsigned i = FirstConstantOper; i != MaxOperands; ++i)
         if (isa<ConstantInt>(GEP1Ops[i]) && 
-            !cast<Constant>(GEP1Ops[i])->isNullValue()) {
+            !cast<ConstantInt>(GEP1Ops[i])->isZero()) {
           // Yup, there's a constant in the tail.  Set all variables to
           // constants in the GEP instruction to make it suiteable for
           // TargetData::getIndexedOffset.
@@ -687,7 +697,7 @@ BasicAliasAnalysis::CheckGEPInstructions(
           if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty)) {
             if (Op1C->getZExtValue() >= AT->getNumElements())
               return MayAlias;  // Be conservative with out-of-range accesses
-          } else if (const PackedType *PT = dyn_cast<PackedType>(BasePtr1Ty)) {
+          } else if (const VectorType *PT = dyn_cast<VectorType>(BasePtr1Ty)) {
             if (Op1C->getZExtValue() >= PT->getNumElements())
               return MayAlias;  // Be conservative with out-of-range accesses
           }
@@ -705,7 +715,7 @@ BasicAliasAnalysis::CheckGEPInstructions(
           //
           if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty))
             GEP1Ops[i] = ConstantInt::get(Type::Int64Ty,AT->getNumElements()-1);
-          else if (const PackedType *PT = dyn_cast<PackedType>(BasePtr1Ty))
+          else if (const VectorType *PT = dyn_cast<VectorType>(BasePtr1Ty))
             GEP1Ops[i] = ConstantInt::get(Type::Int64Ty,PT->getNumElements()-1);
 
         }
@@ -717,7 +727,7 @@ BasicAliasAnalysis::CheckGEPInstructions(
           if (const ArrayType *AT = dyn_cast<ArrayType>(BasePtr1Ty)) {
             if (Op2C->getZExtValue() >= AT->getNumElements())
               return MayAlias;  // Be conservative with out-of-range accesses
-          } else if (const PackedType *PT = dyn_cast<PackedType>(BasePtr1Ty)) {
+          } else if (const VectorType *PT = dyn_cast<VectorType>(BasePtr1Ty)) {
             if (Op2C->getZExtValue() >= PT->getNumElements())
               return MayAlias;  // Be conservative with out-of-range accesses
           }