diff options
author | Chris Lattner <sabre@nondot.org> | 2007-08-04 23:48:07 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2007-08-04 23:48:07 +0000 |
commit | bd0fe01dafb7f115a882865494d139edd8a7f0a2 (patch) | |
tree | f0647fcb514fd9c7cbd1c20508bd335f3d501834 /llvm/lib/VMCore/Dominators.cpp | |
parent | edce70d2fe48d5134baaa50db1c311d02ee275ae (diff) | |
download | bcm5719-llvm-bd0fe01dafb7f115a882865494d139edd8a7f0a2.tar.gz bcm5719-llvm-bd0fe01dafb7f115a882865494d139edd8a7f0a2.zip |
switch the DomTreeNodes and IDoms maps in idom/postidom to a
DenseMap instead of an std::map. This speeds up postdomtree
by about 25% and domtree by about 23%. It also speeds up clients,
for example, domfrontier by 11%, mem2reg by 4% and ADCE by 6%.
llvm-svn: 40826
Diffstat (limited to 'llvm/lib/VMCore/Dominators.cpp')
-rw-r--r-- | llvm/lib/VMCore/Dominators.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/llvm/lib/VMCore/Dominators.cpp b/llvm/lib/VMCore/Dominators.cpp index 91b422c7044..9b36e1de637 100644 --- a/llvm/lib/VMCore/Dominators.cpp +++ b/llvm/lib/VMCore/Dominators.cpp @@ -212,8 +212,7 @@ void DominatorTree::Compress(BasicBlock *VIn) { std::vector<BasicBlock *> Work; std::set<BasicBlock *> Visited; - InfoRec &VInInfo = Info[VIn]; - BasicBlock *VInAncestor = VInInfo.Ancestor; + BasicBlock *VInAncestor = Info[VIn].Ancestor; InfoRec &VInVAInfo = Info[VInAncestor]; if (VInVAInfo.Ancestor != 0) @@ -233,7 +232,7 @@ void DominatorTree::Compress(BasicBlock *VIn) { } Work.pop_back(); - // Update VINfo based on Ancestor info + // Update VInfo based on Ancestor info if (VAInfo.Ancestor == 0) continue; BasicBlock *VAncestorLabel = VAInfo.Label; @@ -366,17 +365,16 @@ void DominatorTree::calculate(Function& F) { // Loop over all of the reachable blocks in the function... for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) if (BasicBlock *ImmDom = getIDom(I)) { // Reachable block. - DomTreeNode *&BBNode = DomTreeNodes[I]; - if (!BBNode) { // Haven't calculated this node yet? - // Get or calculate the node for the immediate dominator - DomTreeNode *IDomNode = getNodeForBlock(ImmDom); - - // Add a new tree node for this BasicBlock, and link it as a child of - // IDomNode - DomTreeNode *C = new DomTreeNode(I, IDomNode); - DomTreeNodes[I] = C; - BBNode = IDomNode->addChild(C); - } + DomTreeNode *BBNode = DomTreeNodes[I]; + if (BBNode) continue; // Haven't calculated this node yet? + + // Get or calculate the node for the immediate dominator + DomTreeNode *IDomNode = getNodeForBlock(ImmDom); + + // Add a new tree node for this BasicBlock, and link it as a child of + // IDomNode + DomTreeNode *C = new DomTreeNode(I, IDomNode); + DomTreeNodes[I] = IDomNode->addChild(C); } // Free temporary memory used to construct idom's @@ -387,8 +385,7 @@ void DominatorTree::calculate(Function& F) { updateDFSNumbers(); } -void DominatorTreeBase::updateDFSNumbers() -{ +void DominatorTreeBase::updateDFSNumbers() { int dfsnum = 0; // Iterate over all nodes in depth first order. for (unsigned i = 0, e = Roots.size(); i != e; ++i) |