[PATCH] D60755: [NFCI] Improve efficiency of isPotentiallyReachableFromManyDomTree.

Nick Lewycky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 16 00:49:15 PDT 2019


nicholas created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
nicholas added parent revisions: D60754: Add forEachDescendant to DominatorTree., D60753: [NFCI] Split isPotentiallyReachable into two implementations..

df_iterator is intended for directed acyclic graphs, and as such keeps a list of visited nodes to not reenter. There is no need for that complexity when visiting a tree, such as DominatorTree. This reduces the amount of work done for each dominated node.


https://reviews.llvm.org/D60755

Files:
  llvm/lib/Analysis/CFG.cpp


Index: llvm/lib/Analysis/CFG.cpp
===================================================================
--- llvm/lib/Analysis/CFG.cpp
+++ llvm/lib/Analysis/CFG.cpp
@@ -165,13 +165,13 @@
 
     // The dominance check effectively visits all blocks dominated by BB. Skip
     // over the domtree-descendants of the block to visit their successors.
-    for (auto I = df_begin(DTN), E = df_end(DTN); I != E; ++I) {
-      for (auto Succ : successors(I->getBlock())) {
+    DT.forEachDescendant(DTN, [&](DomTreeNode *Dominated) {
+      for (auto Succ : successors(Dominated->getBlock())) {
         DomTreeNode *DTSucc = DT.getNode(Succ);
         if (!DT.dominates(DTN, DTSucc))
           Worklist.push_back(DTSucc);
       }
-    }
+    });
   } while (!Worklist.empty());
 
   // We have exhausted all possible paths and are certain that 'To' can not be


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D60755.195314.patch
Type: text/x-patch
Size: 851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190416/eaffac67/attachment.bin>


More information about the llvm-commits mailing list