Make use of "external" depth-first iterators to avoid revisiting nodes
authorChris Lattner <sabre@nondot.org>
Mon, 13 Oct 2003 16:36:06 +0000 (16:36 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 13 Oct 2003 16:36:06 +0000 (16:36 +0000)
multiple times.  This reduces the time to construct post-dominance sets a LOT.
For example, optimizing perlbmk goes from taking 12.9894s to 1.4074s.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9091 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/PostDominators.cpp

index f97fda854e56791d2b1ef041220a2210553cfb82..2ff5fd331ab4c07c6c331026a02aee4a5bee11f9 100644 (file)
@@ -51,12 +51,12 @@ bool PostDominatorSet::runOnFunction(Function &F) {
   do {
     Changed = false;
 
-    std::set<const BasicBlock*> Visited;
+    std::set<BasicBlock*> Visited;
     DomSetType WorkingSet;
 
     for (unsigned i = 0, e = Roots.size(); i != e; ++i)
-      for (idf_iterator<BasicBlock*> It = idf_begin(Roots[i]),
-             E = idf_end(Roots[i]); It != E; ++It) {
+      for (idf_ext_iterator<BasicBlock*> It = idf_ext_begin(Roots[i], Visited),
+             E = idf_ext_end(Roots[i], Visited); It != E; ++It) {
         BasicBlock *BB = *It;
         succ_iterator SI = succ_begin(BB), SE = succ_end(BB);
         if (SI != SE) {                // Is there SOME successor?