Add new optional getPassName() virtual function that a Pass can override
[oota-llvm.git] / lib / Transforms / Utils / PromoteMemoryToRegister.cpp
index 8679701e6a7d0233cd27040e2758cfd0ab233b95..3d81a8bde05c08023cd9b08b261ef8450e958f29 100644 (file)
@@ -25,7 +25,7 @@
 #include "llvm/Pass.h"
 #include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/ConstantVals.h"
+#include "llvm/Constant.h"
 
 using std::vector;
 using std::map;
@@ -44,6 +44,8 @@ namespace {
     map<BasicBlock*,vector<PHINode*> > NewPhiNodes; // the PhiNodes we're adding
 
   public:
+    const char *getPassName() const { return "Promote Memory to Register"; }
+
     // runOnFunction - To run this pass, first we calculate the alloca
     // instructions that are safe for promotion, then we promote each one.
     //
@@ -53,6 +55,7 @@ namespace {
     //
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
       AU.addRequired(DominanceFrontier::ID);
+      AU.preservesCFG();
     }
 
   private:
@@ -79,7 +82,7 @@ static inline bool isSafeAlloca(const AllocaInst *AI) {
       if (MAI->hasIndices()) {  // indexed?
         // Allow the access if there is only one index and the index is
         // zero.
-        if (*MAI->idx_begin() != ConstantUInt::get(Type::UIntTy, 0) ||
+        if (*MAI->idx_begin() != Constant::getNullValue(Type::UIntTy) ||
             MAI->idx_begin()+1 != MAI->idx_end())
           return false;
       }