[llvm-commits] CVS: llvm/lib/VMCore/Dominators.cpp

Chris Lattner lattner at cs.uiuc.edu
Sat Dec 6 18:56:01 PST 2003


Changes in directory llvm/lib/VMCore:

Dominators.cpp updated: 1.53 -> 1.54

---
Log message:

The recalclulate method was a nasty hack that was once used by the -cee pass,
which never worked itself.  The cee pass still doesn't work, but it doesn't use
this method anymore anyway, so eliminate the method.



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

Index: llvm/lib/VMCore/Dominators.cpp
diff -u llvm/lib/VMCore/Dominators.cpp:1.53 llvm/lib/VMCore/Dominators.cpp:1.54
--- llvm/lib/VMCore/Dominators.cpp:1.53	Sat Dec  6 18:38:08 2003
+++ llvm/lib/VMCore/Dominators.cpp	Sat Dec  6 18:55:32 2003
@@ -251,20 +251,27 @@
 }
 
 
-void DominatorSet::recalculate() {
+// runOnFunction - This method calculates the forward dominator sets for the
+// specified function.
+//
+bool DominatorSet::runOnFunction(Function &F) {
+  BasicBlock *Root = &F.getEntryBlock();
+  Roots.clear();
+  Roots.push_back(Root);
+  assert(pred_begin(Root) == pred_end(Root) &&
+	 "Root node has predecessors in function!");
+
   ImmediateDominators &ID = getAnalysis<ImmediateDominators>();
   Doms.clear();
-  if (Roots.empty()) return;
+  if (Roots.empty()) return false;
 
   // Root nodes only dominate themselves.
   for (unsigned i = 0, e = Roots.size(); i != e; ++i)
     Doms[Roots[i]].insert(Roots[i]);
 
-  Function *F = Roots.back()->getParent();
-
   // Loop over all of the blocks in the function, calculating dominator sets for
   // each function.
-  for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
+  for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
     if (BasicBlock *IDom = ID[I]) {   // Get idom if block is reachable
       DomSetType &DS = Doms[I];
       assert(DS.empty() && "Domset already filled in for this block?");
@@ -288,18 +295,7 @@
       // is important for the case when there is unreachable blocks.
       Doms[I];
     }
-}
 
-// runOnFunction - This method calculates the forward dominator sets for the
-// specified function.
-//
-bool DominatorSet::runOnFunction(Function &F) {
-  BasicBlock *Root = &F.getEntryBlock();
-  Roots.clear();
-  Roots.push_back(Root);
-  assert(pred_begin(Root) == pred_end(Root) &&
-	 "Root node has predecessors in function!");
-  recalculate();
   return false;
 }
 





More information about the llvm-commits mailing list