diff options
author | Chris Lattner <sabre@nondot.org> | 2001-08-23 17:07:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2001-08-23 17:07:19 +0000 |
commit | a0484c8eeb85d64aab06ec1a6e01b81261140c07 (patch) | |
tree | 240a19b6e14c27b3f65773bf84e75eb4a4f6a856 /llvm/lib/Analysis/PostDominators.cpp | |
parent | 01a45c6c96ab33d8b97b944a7dcac08b2e2d9f28 (diff) | |
download | bcm5719-llvm-a0484c8eeb85d64aab06ec1a6e01b81261140c07.tar.gz bcm5719-llvm-a0484c8eeb85d64aab06ec1a6e01b81261140c07.zip |
Handle case where there is no exit node from a flowgraph
llvm-svn: 365
Diffstat (limited to 'llvm/lib/Analysis/PostDominators.cpp')
-rw-r--r-- | llvm/lib/Analysis/PostDominators.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/llvm/lib/Analysis/PostDominators.cpp b/llvm/lib/Analysis/PostDominators.cpp index 707b5334a5d..24ff4399942 100644 --- a/llvm/lib/Analysis/PostDominators.cpp +++ b/llvm/lib/Analysis/PostDominators.cpp @@ -32,7 +32,8 @@ void set_intersect(set<Ty> &S1, const set<Ty2> &S2) { //===----------------------------------------------------------------------===// bool cfg::DominatorBase::isPostDominator() const { - return Root != Root->getParent()->front(); + // Root can be null if there is no exit node from the CFG and is postdom set + return Root == 0 || Root != Root->getParent()->front(); } @@ -96,7 +97,11 @@ cfg::DominatorSet::DominatorSet(Method *M, bool PostDomSet) if (!PostDomSet) { calcForwardDominatorSet(M); return; } Root = cfg::UnifyAllExitNodes(M); - assert(Root && "TODO: Don't handle case where there are no exit nodes yet!"); + if (Root == 0) { // No exit node for the method? Postdomsets are all empty + for (Method::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI) + Doms[*MI] = DomSetType(); + return; + } bool Changed; do { @@ -255,7 +260,7 @@ void cfg::DominatorTree::calculate(const DominatorSet &DS) { } } } - } else { + } else if (Root) { // Iterate over all nodes in depth first order... for (idf_const_iterator I = idf_begin(Root), E = idf_end(Root); I != E; ++I) { const BasicBlock *BB = *I; @@ -343,6 +348,7 @@ cfg::DominanceFrontier::calcPostDomFrontier(const DominatorTree &DT, // Loop over CFG successors to calculate DFlocal[Node] const BasicBlock *BB = Node->getNode(); DomSetType &S = Frontiers[BB]; // The new set to fill in... + if (!Root) return S; for (pred_const_iterator SI = pred_begin(BB), SE = pred_end(BB); SI != SE; ++SI) { |