From b60f254975a387d58d2d173531c5a9d844c82c47 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 3 Oct 2007 03:20:17 +0000 Subject: Factor some code from the DomTree and PostDomTree calculate methods up into each one's runOnFunction method. llvm-svn: 42563 --- llvm/lib/Analysis/PostDominators.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'llvm/lib/Analysis/PostDominators.cpp') diff --git a/llvm/lib/Analysis/PostDominators.cpp b/llvm/lib/Analysis/PostDominators.cpp index cd29749c830..0ca73882312 100644 --- a/llvm/lib/Analysis/PostDominators.cpp +++ b/llvm/lib/Analysis/PostDominators.cpp @@ -28,6 +28,29 @@ char PostDominanceFrontier::ID = 0; static RegisterPass F("postdomtree", "Post-Dominator Tree Construction", true); +bool PostDominatorTree::runOnFunction(Function &F) { + reset(); // Reset from the last time we were run... + + // Initialize the roots list + 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(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); + + PDTcalculate(*this, F); + return false; +} + //===----------------------------------------------------------------------===// // PostDominanceFrontier Implementation //===----------------------------------------------------------------------===// -- cgit v1.2.3