diff --git a/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h b/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h index ddc0f1c246065..a8fca70159f5f 100644 --- a/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h +++ b/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h @@ -129,7 +129,7 @@ ChildrenGetterTy::get(const NodeRef &N) { template void IDFCalculatorBase::calculate( - SmallVectorImpl &PHIBlocks) { + SmallVectorImpl &IDFBlocks) { // Use a priority queue keyed on dominator tree level so that inserted nodes // are handled from the bottom of the dominator tree upwards. We also augment // the level with a DFS number to ensure that the blocks are ordered in a @@ -144,15 +144,16 @@ void IDFCalculatorBase::calculate( DT.updateDFSNumbers(); - for (NodeTy *BB : *DefBlocks) { - if (DomTreeNodeBase *Node = DT.getNode(BB)) - PQ.push({Node, std::make_pair(Node->getLevel(), Node->getDFSNumIn())}); - } - SmallVector *, 32> Worklist; SmallPtrSet *, 32> VisitedPQ; SmallPtrSet *, 32> VisitedWorklist; + for (NodeTy *BB : *DefBlocks) + if (DomTreeNodeBase *Node = DT.getNode(BB)) { + PQ.push({Node, std::make_pair(Node->getLevel(), Node->getDFSNumIn())}); + VisitedWorklist.insert(Node); + } + while (!PQ.empty()) { DomTreeNodePair RootPair = PQ.top(); PQ.pop(); @@ -164,9 +165,8 @@ void IDFCalculatorBase::calculate( // most Root's level are added to the iterated dominance frontier of the // definition set. - Worklist.clear(); + assert(Worklist.empty()); Worklist.push_back(Root); - VisitedWorklist.insert(Root); while (!Worklist.empty()) { DomTreeNodeBase *Node = Worklist.pop_back_val(); @@ -187,7 +187,7 @@ void IDFCalculatorBase::calculate( if (useLiveIn && !LiveInBlocks->count(SuccBB)) return; - PHIBlocks.emplace_back(SuccBB); + IDFBlocks.emplace_back(SuccBB); if (!DefBlocks->count(SuccBB)) PQ.push(std::make_pair( SuccNode, std::make_pair(SuccLevel, SuccNode->getDFSNumIn())));