aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/PostDominators.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Analysis/PostDominators.cpp')
-rw-r--r--lib/Analysis/PostDominators.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Analysis/PostDominators.cpp b/lib/Analysis/PostDominators.cpp
index 48f7b30..1188cff 100644
--- a/lib/Analysis/PostDominators.cpp
+++ b/lib/Analysis/PostDominators.cpp
@@ -112,8 +112,12 @@ void PostDominatorTree::calculate(Function &F) {
// 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))
- Roots.push_back(I);
+ if (succ_begin(I) == succ_end(I)) {
+ Instruction *Insn = I->getTerminator();
+ // Unreachable block is not a root node.
+ if (!isa<UnreachableInst>(Insn))
+ Roots.push_back(I);
+ }
Vertex.push_back(0);