[llvm-commits] CVS: llvm/lib/Transforms/Utils/Mem2Reg.cpp PromoteMemoryToRegister.cpp

Owen Anderson resistor at mac.com
Thu Apr 19 23:27:34 PDT 2007



Changes in directory llvm/lib/Transforms/Utils:

Mem2Reg.cpp updated: 1.23 -> 1.24
PromoteMemoryToRegister.cpp updated: 1.96 -> 1.97
---
Log message:

Move more passes to using ETForest instead of DominatorTree.


---
Diffs of the changes:  (+12 -13)

 Mem2Reg.cpp                 |    6 +++---
 PromoteMemoryToRegister.cpp |   19 +++++++++----------
 2 files changed, 12 insertions(+), 13 deletions(-)


Index: llvm/lib/Transforms/Utils/Mem2Reg.cpp
diff -u llvm/lib/Transforms/Utils/Mem2Reg.cpp:1.23 llvm/lib/Transforms/Utils/Mem2Reg.cpp:1.24
--- llvm/lib/Transforms/Utils/Mem2Reg.cpp:1.23	Mon Apr 16 13:10:23 2007
+++ llvm/lib/Transforms/Utils/Mem2Reg.cpp	Fri Apr 20 01:27:13 2007
@@ -36,7 +36,7 @@
     // getAnalysisUsage - We need dominance frontiers
     //
     virtual void getAnalysisUsage(AnalysisUsage &AU) const {
-      AU.addRequired<DominatorTree>();
+      AU.addRequired<ETForest>();
       AU.addRequired<DominanceFrontier>();
       AU.addRequired<TargetData>();
       AU.setPreservesCFG();
@@ -60,7 +60,7 @@
 
   bool Changed  = false;
 
-  DominatorTree     &DT = getAnalysis<DominatorTree>();
+  ETForest     &ET = getAnalysis<ETForest>();
   DominanceFrontier &DF = getAnalysis<DominanceFrontier>();
 
   while (1) {
@@ -75,7 +75,7 @@
 
     if (Allocas.empty()) break;
 
-    PromoteMemToReg(Allocas, DT, DF, TD);
+    PromoteMemToReg(Allocas, ET, DF, TD);
     NumPromoted += Allocas.size();
     Changed = true;
   }


Index: llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff -u llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.96 llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.97
--- llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp:1.96	Mon Mar 26 18:19:29 2007
+++ llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp	Fri Apr 20 01:27:13 2007
@@ -88,7 +88,7 @@
     ///
     std::vector<AllocaInst*> Allocas;
     SmallVector<AllocaInst*, 16> &RetryList;
-    DominatorTree &DT;
+    ETForest &ET;
     DominanceFrontier &DF;
     const TargetData &TD;
 
@@ -127,10 +127,10 @@
 
   public:
     PromoteMem2Reg(const std::vector<AllocaInst*> &A,
-                   SmallVector<AllocaInst*, 16> &Retry, DominatorTree &dt,
+                   SmallVector<AllocaInst*, 16> &Retry, ETForest &et,
                    DominanceFrontier &df, const TargetData &td,
                    AliasSetTracker *ast)
-      : Allocas(A), RetryList(Retry), DT(dt), DF(df), TD(td), AST(ast) {}
+      : Allocas(A), RetryList(Retry), ET(et), DF(df), TD(td), AST(ast) {}
 
     void run();
 
@@ -139,13 +139,13 @@
     bool properlyDominates(Instruction *I1, Instruction *I2) const {
       if (InvokeInst *II = dyn_cast<InvokeInst>(I1))
         I1 = II->getNormalDest()->begin();
-      return DT[I1->getParent()]->properlyDominates(DT[I2->getParent()]);
+      return ET.properlyDominates(I1->getParent(), I2->getParent());
     }
     
     /// dominates - Return true if BB1 dominates BB2 using the DominatorTree.
     ///
     bool dominates(BasicBlock *BB1, BasicBlock *BB2) const {
-      return DT[BB1]->dominates(DT[BB2]);
+      return ET.dominates(BB1, BB2);
     }
 
   private:
@@ -534,8 +534,7 @@
                                       SmallPtrSet<PHINode*, 16> &DeadPHINodes) {
   // Scan the immediate dominators of this block looking for a block which has a
   // PHI node for Alloca num.  If we find it, mark the PHI node as being alive!
-  for (DominatorTree::Node *N = DT[BB]; N; N = N->getIDom()) {
-    BasicBlock *DomBB = N->getBlock();
+  for (BasicBlock* DomBB = BB; DomBB; DomBB = ET.getIDom(DomBB)) {
     DenseMap<std::pair<BasicBlock*, unsigned>, PHINode*>::iterator
       I = NewPhiNodes.find(std::make_pair(DomBB, AllocaNum));
     if (I != NewPhiNodes.end()) {
@@ -806,13 +805,13 @@
 /// made to the IR.
 ///
 void llvm::PromoteMemToReg(const std::vector<AllocaInst*> &Allocas,
-                           DominatorTree &DT, DominanceFrontier &DF,
+                           ETForest &ET, DominanceFrontier &DF,
                            const TargetData &TD, AliasSetTracker *AST) {
   // If there is nothing to do, bail out...
   if (Allocas.empty()) return;
 
   SmallVector<AllocaInst*, 16> RetryList;
-  PromoteMem2Reg(Allocas, RetryList, DT, DF, TD, AST).run();
+  PromoteMem2Reg(Allocas, RetryList, ET, DF, TD, AST).run();
 
   // PromoteMem2Reg may not have been able to promote all of the allocas in one
   // pass, run it again if needed.
@@ -830,7 +829,7 @@
 
     NewAllocas.assign(RetryList.begin(), RetryList.end());
     RetryList.clear();
-    PromoteMem2Reg(NewAllocas, RetryList, DT, DF, TD, AST).run();
+    PromoteMem2Reg(NewAllocas, RetryList, ET, DF, TD, AST).run();
     NewAllocas.clear();
   }
 }






More information about the llvm-commits mailing list