aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-07-24 01:02:25 +0000
committerDevang Patel <dpatel@apple.com>2007-07-24 01:02:25 +0000
commit34ef1449c5cbee6fa5b97e31eb7df2d8477c646a (patch)
tree6cfa14dc1f5be3e697d74494b99053f1771648b3
parenta19580ccc003d2c236526cb7bcf76bda744260f3 (diff)
downloadexternal_llvm-34ef1449c5cbee6fa5b97e31eb7df2d8477c646a.zip
external_llvm-34ef1449c5cbee6fa5b97e31eb7df2d8477c646a.tar.gz
external_llvm-34ef1449c5cbee6fa5b97e31eb7df2d8477c646a.tar.bz2
Unreachable block is not a root node in post dominator tree.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40458 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Analysis/PostDominators.cpp8
-rw-r--r--test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll13
2 files changed, 19 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);
diff --git a/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll b/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll
new file mode 100644
index 0000000..f3500ed
--- /dev/null
+++ b/test/Transforms/ADCE/2007-07-23-InfiniteLoop.ll
@@ -0,0 +1,13 @@
+; RUN: llvm-as < %s | opt -adce | llvm-dis | grep switch
+; PR 1564
+
+define fastcc void @out() {
+ start:
+ br label %loop
+ unreachable:
+ unreachable
+ loop:
+ switch i32 0, label %unreachable [
+ i32 0, label %loop
+ ]
+}