Eliminate the cfg namespace, moving LoopInfo, Dominators, Interval* classes
[oota-llvm.git] / lib / Transforms / Utils / PromoteMemoryToRegister.cpp
index 79c03864d86259ce29dd519afe1ab9f26b8d43fb..bbb131fabfb7a39920f0734432bd85694be0d899 100644 (file)
 #include "llvm/Transforms/Scalar/PromoteMemoryToRegister.h"
 #include "llvm/Analysis/Dominators.h"
 #include "llvm/iMemory.h"
+#include "llvm/iPHINode.h"
+#include "llvm/iTerminators.h"
 #include "llvm/Pass.h"
 #include "llvm/Function.h"
 #include "llvm/BasicBlock.h"
-#include "llvm/Assembly/Writer.h"  // For debugging
-#include "llvm/iPHINode.h"
-#include "llvm/iTerminators.h"
+#include "llvm/ConstantVals.h"
 
 using namespace std;
 
-
-using cfg::DominanceFrontier;
-
 namespace {
 
 //instance of the promoter -- to keep all the local function data.
@@ -141,8 +138,8 @@ bool PromoteInstance::PromoteFunction(Function *F, DominanceFrontier & DF) {
                        DominanceFrontier::DomSetType     s = (*it).second;
                        for (DominanceFrontier::DomSetType::iterator p = s.begin();p!=s.end(); ++p)
                        {
-                               if (queuePhiNode((BasicBlock *)*p, i))
-                               PhiNodes[i].push_back((BasicBlock *)*p);
+                               if (queuePhiNode(*p, i))
+                                  PhiNodes[i].push_back(*p);
                        }
                }
                // perform iterative step
@@ -152,8 +149,8 @@ bool PromoteInstance::PromoteFunction(Function *F, DominanceFrontier & DF) {
                        DominanceFrontier::DomSetType     s = it->second;
                        for (DominanceFrontier::DomSetType::iterator p = s.begin(); p!=s.end(); ++p)
                        {
-                               if (queuePhiNode((BasicBlock *)*p,i))
-                               PhiNodes[i].push_back((BasicBlock*)*p);
+                               if (queuePhiNode(*p,i))
+                               PhiNodes[i].push_back(*p);
                        }
                }
        }
@@ -309,22 +306,20 @@ bool PromoteInstance::queuePhiNode(BasicBlock *bb, int i /*the alloca*/)
 
 
 namespace {
-  struct PromotePass : public MethodPass {
+  struct PromotePass : public FunctionPass {
 
-    // runOnMethod - To run this pass, first we calculate the alloca
+    // runOnFunction - To run this pass, first we calculate the alloca
     // instructions that are safe for promotion, then we promote each one.
     //
-    virtual bool runOnMethod(Function *F) {
+    virtual bool runOnFunction(Function *F) {
       return (bool)PromoteInstance(F, getAnalysis<DominanceFrontier>());
     }
     
 
-    // getAnalysisUsageInfo - We need dominance frontiers
+    // getAnalysisUsage - We need dominance frontiers
     //
-    virtual void getAnalysisUsageInfo(Pass::AnalysisSet &Requires,
-                                     Pass::AnalysisSet &Destroyed,
-                                     Pass::AnalysisSet &Provided) {
-      Requires.push_back(DominanceFrontier::ID);
+    virtual void getAnalysisUsage(AnalysisUsage &AU) const {
+      AU.addRequired(DominanceFrontier::ID);
     }
   };
 }