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

Devang Patel dpatel at apple.com
Mon Jun 11 14:18:23 PDT 2007



Changes in directory llvm/lib/Transforms/Utils:

LoopSimplify.cpp updated: 1.100 -> 1.101
---
Log message:

Simplify.  Dominator Tree is required so always available.


---
Diffs of the changes:  (+26 -31)

 LoopSimplify.cpp |   57 +++++++++++++++++++++++++------------------------------
 1 files changed, 26 insertions(+), 31 deletions(-)


Index: llvm/lib/Transforms/Utils/LoopSimplify.cpp
diff -u llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.100 llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.101
--- llvm/lib/Transforms/Utils/LoopSimplify.cpp:1.100	Thu Jun  7 20:50:32 2007
+++ llvm/lib/Transforms/Utils/LoopSimplify.cpp	Mon Jun 11 16:18:00 2007
@@ -693,9 +693,8 @@
   return false;
 }
 
-/// UpdateDomInfoForRevectoredPreds - This method is used to update the four
-/// different kinds of dominator information (immediate dominators,
-/// dominator trees, et-forest and dominance frontiers) after a new block has
+/// UpdateDomInfoForRevectoredPreds - This method is used to update
+/// dominator trees and dominance frontiers after a new block has
 /// been added to the CFG.
 ///
 /// This only supports the case when an existing block (known as "NewBBSucc"),
@@ -756,38 +755,34 @@
       }
   }
 
-  BasicBlock *NewBBIDom = 0;
 
   // Update DominatorTree information if it is active.
-  if (DominatorTree *DT = getAnalysisToUpdate<DominatorTree>()) {
-    // If we don't have ImmediateDominator info around, calculate the idom as
-    // above.
-    if (!NewBBIDom) {
-      unsigned i = 0;
-      for (i = 0; i < PredBlocks.size(); ++i)
-        if (DT->dominates(&PredBlocks[i]->getParent()->getEntryBlock(), 
-                                  PredBlocks[i])) {
-          NewBBIDom = PredBlocks[i];
-          break;
-        }
-      assert(i != PredBlocks.size() && "No reachable preds?");
-      for (i = i + 1; i < PredBlocks.size(); ++i) {
-        if (DT->dominates(&PredBlocks[i]->getParent()->getEntryBlock(), 
-                                  PredBlocks[i]))
-          NewBBIDom = DT->nearestCommonDominator(NewBBIDom, PredBlocks[i]);
-      }
-      assert(NewBBIDom && "No immediate dominator found??");
-    }
 
-    // Create the new dominator tree node... and set the idom of NewBB.
-    DomTreeNode *NewBBNode = DT->addNewBlock(NewBB, NewBBIDom);
-
-    // If NewBB strictly dominates other blocks, then it is now the immediate
-    // dominator of NewBBSucc.  Update the dominator tree as appropriate.
-    if (NewBBDominatesNewBBSucc) {
-      DomTreeNode *NewBBSuccNode = DT->getNode(NewBBSucc);
-      DT->changeImmediateDominator(NewBBSuccNode, NewBBNode);
+  // Find NewBB's immediate dominator and create new dominator tree node for NewBB.
+  BasicBlock *NewBBIDom = 0;
+  unsigned i = 0;
+  for (i = 0; i < PredBlocks.size(); ++i)
+    if (DT.dominates(&PredBlocks[i]->getParent()->getEntryBlock(), 
+                     PredBlocks[i])) {
+      NewBBIDom = PredBlocks[i];
+      break;
     }
+  assert(i != PredBlocks.size() && "No reachable preds?");
+  for (i = i + 1; i < PredBlocks.size(); ++i) {
+    if (DT.dominates(&PredBlocks[i]->getParent()->getEntryBlock(), 
+                      PredBlocks[i]))
+      NewBBIDom = DT.nearestCommonDominator(NewBBIDom, PredBlocks[i]);
+  }
+  assert(NewBBIDom && "No immediate dominator found??");
+  
+  // Create the new dominator tree node... and set the idom of NewBB.
+  DomTreeNode *NewBBNode = DT.addNewBlock(NewBB, NewBBIDom);
+  
+  // If NewBB strictly dominates other blocks, then it is now the immediate
+  // dominator of NewBBSucc.  Update the dominator tree as appropriate.
+  if (NewBBDominatesNewBBSucc) {
+    DomTreeNode *NewBBSuccNode = DT.getNode(NewBBSucc);
+    DT.changeImmediateDominator(NewBBSuccNode, NewBBNode);
   }
 
   // Update dominance frontier information...






More information about the llvm-commits mailing list