Skip to content

Commit

Permalink
[Dominators] Teach IDF to use level information
Browse files Browse the repository at this point in the history
Summary: This patch teaches IteratedDominanceFrontier to use the level information stored in DomTreeNodes instead of calculating it manually.

Reviewers: dberlin, sanjoy, davide

Reviewed By: davide

Subscribers: davide, llvm-commits

Differential Revision: https://reviews.llvm.org/D34703

llvm-svn: 306894
  • Loading branch information
kuhar committed Jun 30, 2017
1 parent 3214633 commit c008779
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
1 change: 0 additions & 1 deletion llvm/include/llvm/Analysis/IteratedDominanceFrontier.h
Expand Up @@ -86,7 +86,6 @@ class IDFCalculator {
private:
DominatorTreeBase<BasicBlock> &DT;
bool useLiveIn;
DenseMap<DomTreeNode *, unsigned> DomLevels;
const SmallPtrSetImpl<BasicBlock *> *LiveInBlocks;
const SmallPtrSetImpl<BasicBlock *> *DefBlocks;
};
Expand Down
12 changes: 2 additions & 10 deletions llvm/lib/Analysis/IteratedDominanceFrontier.cpp
Expand Up @@ -20,14 +20,6 @@ namespace llvm {
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;
Expand All @@ -37,7 +29,7 @@ void IDFCalculator<NodeTy>::calculate(

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;
Expand Down Expand Up @@ -72,7 +64,7 @@ void IDFCalculator<NodeTy>::calculate(
if (SuccNode->getIDom() == Node)
continue;

unsigned SuccLevel = DomLevels.lookup(SuccNode);
const unsigned SuccLevel = SuccNode->getLevel();
if (SuccLevel > RootLevel)
continue;

Expand Down

0 comments on commit c008779

Please sign in to comment.