[PATCH] D34703: [Dominators] Teach IDF to use level information

Jakub Kuderski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 27 11:57:38 PDT 2017


kuhar created this revision.

This patch teaches IteratedDominanceFrontier to use the level information stored in DomTreeNodes instead of calculating it manually.


https://reviews.llvm.org/D34703

Files:
  include/llvm/Analysis/IteratedDominanceFrontier.h
  lib/Analysis/IteratedDominanceFrontier.cpp


Index: lib/Analysis/IteratedDominanceFrontier.cpp
===================================================================
--- lib/Analysis/IteratedDominanceFrontier.cpp
+++ lib/Analysis/IteratedDominanceFrontier.cpp
@@ -20,14 +20,6 @@
 template <class NodeTy>
 void IDFCalculator<NodeTy>::calculate(
     SmallVectorImpl<BasicBlock *> &PHIBlocks) {
-  // If we haven't computed dominator tree levels, do so now.
-  if (DomLevels.empty()) {
-    for (auto DFI = df_begin(DT.getRootNode()), DFE = df_end(DT.getRootNode());
-         DFI != DFE; ++DFI) {
-      DomLevels[*DFI] = DFI.getPathLength() - 1;
-    }
-  }
-
   // Use a priority queue keyed on dominator tree level so that inserted nodes
   // are handled from the bottom of the dominator tree upwards.
   typedef std::pair<DomTreeNode *, unsigned> DomTreeNodePair;
@@ -37,7 +29,7 @@
 
   for (BasicBlock *BB : *DefBlocks) {
     if (DomTreeNode *Node = DT.getNode(BB))
-      PQ.push(std::make_pair(Node, DomLevels.lookup(Node)));
+      PQ.push({Node, Node->getLevel()});
   }
 
   SmallVector<DomTreeNode *, 32> Worklist;
@@ -72,7 +64,7 @@
         if (SuccNode->getIDom() == Node)
           continue;
 
-        unsigned SuccLevel = DomLevels.lookup(SuccNode);
+        const unsigned SuccLevel = SuccNode->getLevel();
         if (SuccLevel > RootLevel)
           continue;
 
Index: include/llvm/Analysis/IteratedDominanceFrontier.h
===================================================================
--- include/llvm/Analysis/IteratedDominanceFrontier.h
+++ include/llvm/Analysis/IteratedDominanceFrontier.h
@@ -86,7 +86,6 @@
 private:
   DominatorTreeBase<BasicBlock> &DT;
   bool useLiveIn;
-  DenseMap<DomTreeNode *, unsigned> DomLevels;
   const SmallPtrSetImpl<BasicBlock *> *LiveInBlocks;
   const SmallPtrSetImpl<BasicBlock *> *DefBlocks;
 };


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34703.104230.patch
Type: text/x-patch
Size: 1812 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170627/74192f89/attachment.bin>


More information about the llvm-commits mailing list