Expose new "recalculate" method from dominatorset
authorChris Lattner <sabre@nondot.org>
Tue, 8 Oct 2002 19:12:08 +0000 (19:12 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 8 Oct 2002 19:12:08 +0000 (19:12 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4074 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/Dominators.h
lib/VMCore/Dominators.cpp

index 81f0eaf76dd1bdf895d1ace10b6d6ff44f3f1dce..815be7dfaf35cebf74c0ab19c207c816611e5374 100644 (file)
@@ -128,6 +128,11 @@ struct DominatorSet : public DominatorSetBase {
 
   virtual bool runOnFunction(Function &F);
 
+  /// recalculate - This method may be called by external passes that modify the
+  /// CFG and then need dominator information recalculated.  This method is
+  /// obviously really slow, so it should be avoided if at all possible.
+  void recalculate();
+
   // getAnalysisUsage - This simply provides a dominator set
   virtual void getAnalysisUsage(AnalysisUsage &AU) const {
     AU.setPreservesAll();
index 37e7d48c283919f23283f5ce44ef6c25b077b77e..a9479aa635517de8430e993069b530152d4ffe4b 100644 (file)
@@ -92,10 +92,15 @@ void DominatorSet::calculateDominatorsFromBlock(BasicBlock *RootBB) {
 // specified function.
 //
 bool DominatorSet::runOnFunction(Function &F) {
-  Doms.clear();   // Reset from the last time we were run...
   Root = &F.getEntryNode();
   assert(pred_begin(Root) == pred_end(Root) &&
         "Root node has predecessors in function!");
+  recalculate();
+  return false;
+}
+
+void DominatorSet::recalculate() {
+  Doms.clear();   // Reset from the last time we were run...
 
   // Calculate dominator sets for the reachable basic blocks...
   calculateDominatorsFromBlock(Root);
@@ -106,11 +111,10 @@ bool DominatorSet::runOnFunction(Function &F) {
   // extra pass over the function, calculating dominator information for
   // unreachable blocks.
   //
-  for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
+  Function *F = Root->getParent();
+  for (Function::iterator I = F->begin(), E = F->end(); I != E; ++I)
     if (Doms[I].count(I) == 0)
       calculateDominatorsFromBlock(I);
-
-  return false;
 }