aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/PostDominators.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-08-04 23:48:07 +0000
committerChris Lattner <sabre@nondot.org>2007-08-04 23:48:07 +0000
commitbd0fe01dafb7f115a882865494d139edd8a7f0a2 (patch)
treef0647fcb514fd9c7cbd1c20508bd335f3d501834 /llvm/lib/Analysis/PostDominators.cpp
parentedce70d2fe48d5134baaa50db1c311d02ee275ae (diff)
downloadllvm-bd0fe01dafb7f115a882865494d139edd8a7f0a2.zip
llvm-bd0fe01dafb7f115a882865494d139edd8a7f0a2.tar.gz
llvm-bd0fe01dafb7f115a882865494d139edd8a7f0a2.tar.bz2
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/Analysis/PostDominators.cpp')
-rw-r--r--llvm/lib/Analysis/PostDominators.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/PostDominators.cpp b/llvm/lib/Analysis/PostDominators.cpp
index 1188cff..e3169a5 100644
--- a/llvm/lib/Analysis/PostDominators.cpp
+++ b/llvm/lib/Analysis/PostDominators.cpp
@@ -28,7 +28,7 @@ static RegisterPass<PostDominatorTree>
F("postdomtree", "Post-Dominator Tree Construction", true);
unsigned PostDominatorTree::DFSPass(BasicBlock *V, InfoRec &VInfo,
- unsigned N) {
+ unsigned N) {
std::vector<std::pair<BasicBlock *, InfoRec *> > workStack;
std::set<BasicBlock *> visited;
workStack.push_back(std::make_pair(V, &VInfo));
@@ -111,13 +111,18 @@ void PostDominatorTree::calculate(Function &F) {
// Step #0: Scan the function looking for the root nodes of the post-dominance
// relationships. These blocks, which have no successors, end with return and
// unwind instructions.
- for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I)
- if (succ_begin(I) == succ_end(I)) {
- Instruction *Insn = I->getTerminator();
+ for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) {
+ TerminatorInst *Insn = I->getTerminator();
+ if (Insn->getNumSuccessors() == 0) {
// Unreachable block is not a root node.
if (!isa<UnreachableInst>(Insn))
Roots.push_back(I);
}
+
+ // Prepopulate maps so that we don't get iterator invalidation issues later.
+ IDoms[I] = 0;
+ DomTreeNodes[I] = 0;
+ }
Vertex.push_back(0);