mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-20 19:42:54 +02:00
Eliminate O(n^2) worst-case behavior in SSA construction
The code uses a priority queue and a worklist, which share the same visited set, but the visited set is only updated when inserting into the priority queue. Instead, switch to using separate visited sets for the priority queue and worklist. llvm-svn: 234425
This commit is contained in:
parent
23b1ef3354
commit
f48f486c1d
@ -872,8 +872,10 @@ void PromoteMem2Reg::DetermineInsertionPoint(AllocaInst *AI, unsigned AllocaNum,
|
||||
}
|
||||
|
||||
SmallVector<std::pair<unsigned, BasicBlock *>, 32> DFBlocks;
|
||||
SmallPtrSet<DomTreeNode *, 32> Visited;
|
||||
SmallVector<DomTreeNode *, 32> Worklist;
|
||||
SmallPtrSet<DomTreeNode *, 32> VisitedPQ;
|
||||
SmallPtrSet<DomTreeNode *, 32> VisitedWorklist;
|
||||
|
||||
while (!PQ.empty()) {
|
||||
DomTreeNodePair RootPair = PQ.top();
|
||||
PQ.pop();
|
||||
@ -887,6 +889,7 @@ void PromoteMem2Reg::DetermineInsertionPoint(AllocaInst *AI, unsigned AllocaNum,
|
||||
|
||||
Worklist.clear();
|
||||
Worklist.push_back(Root);
|
||||
VisitedWorklist.insert(Root);
|
||||
|
||||
while (!Worklist.empty()) {
|
||||
DomTreeNode *Node = Worklist.pop_back_val();
|
||||
@ -905,7 +908,7 @@ void PromoteMem2Reg::DetermineInsertionPoint(AllocaInst *AI, unsigned AllocaNum,
|
||||
if (SuccLevel > RootLevel)
|
||||
continue;
|
||||
|
||||
if (!Visited.insert(SuccNode).second)
|
||||
if (!VisitedPQ.insert(SuccNode).second)
|
||||
continue;
|
||||
|
||||
BasicBlock *SuccBB = SuccNode->getBlock();
|
||||
@ -919,7 +922,7 @@ void PromoteMem2Reg::DetermineInsertionPoint(AllocaInst *AI, unsigned AllocaNum,
|
||||
|
||||
for (DomTreeNode::iterator CI = Node->begin(), CE = Node->end(); CI != CE;
|
||||
++CI) {
|
||||
if (!Visited.count(*CI))
|
||||
if (VisitedWorklist.insert(*CI).second)
|
||||
Worklist.push_back(*CI);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user