[llvm] c831129 - [IteratedDominanceFrontier] Decrease number of SmallPtrSet::insert and delete unneeded SmallVector::clear
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 13 19:51:23 PDT 2020
Author: Fangrui Song
Date: 2020-06-13T19:48:50-07:00
New Revision: c83112958d7a1657ce942fa6c7b2db2ec901d7e5
URL: https://github.com/llvm/llvm-project/commit/c83112958d7a1657ce942fa6c7b2db2ec901d7e5
DIFF: https://github.com/llvm/llvm-project/commit/c83112958d7a1657ce942fa6c7b2db2ec901d7e5.diff
LOG: [IteratedDominanceFrontier] Decrease number of SmallPtrSet::insert and delete unneeded SmallVector::clear
Also, fix the argument name to be consistent with the declaration.
Added:
Modified:
llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h b/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h
index ddc0f1c24606..a8fca70159f5 100644
--- a/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h
+++ b/llvm/include/llvm/Support/GenericIteratedDominanceFrontier.h
@@ -129,7 +129,7 @@ ChildrenGetterTy<NodeTy, IsPostDom>::get(const NodeRef &N) {
template <class NodeTy, bool IsPostDom>
void IDFCalculatorBase<NodeTy, IsPostDom>::calculate(
- SmallVectorImpl<NodeTy *> &PHIBlocks) {
+ SmallVectorImpl<NodeTy *> &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<NodeTy, IsPostDom>::calculate(
DT.updateDFSNumbers();
- for (NodeTy *BB : *DefBlocks) {
- if (DomTreeNodeBase<NodeTy> *Node = DT.getNode(BB))
- PQ.push({Node, std::make_pair(Node->getLevel(), Node->getDFSNumIn())});
- }
-
SmallVector<DomTreeNodeBase<NodeTy> *, 32> Worklist;
SmallPtrSet<DomTreeNodeBase<NodeTy> *, 32> VisitedPQ;
SmallPtrSet<DomTreeNodeBase<NodeTy> *, 32> VisitedWorklist;
+ for (NodeTy *BB : *DefBlocks)
+ if (DomTreeNodeBase<NodeTy> *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<NodeTy, IsPostDom>::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<NodeTy> *Node = Worklist.pop_back_val();
@@ -187,7 +187,7 @@ void IDFCalculatorBase<NodeTy, IsPostDom>::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())));
More information about the llvm-commits
mailing list