summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNuno Lopes <nunoplopes@sapo.pt>2012-07-16 22:49:40 +0000
committerNuno Lopes <nunoplopes@sapo.pt>2012-07-16 22:49:40 +0000
commit482fb19fd52d2f1c3817d475bbe7d7df532fe1c4 (patch)
tree4a957b64736c982f177bb04cad662aff428fc80c
parentaa9f35a6b64a825b5432abaedc84e71e70d22292 (diff)
downloadbcm5719-llvm-482fb19fd52d2f1c3817d475bbe7d7df532fe1c4.tar.gz
bcm5719-llvm-482fb19fd52d2f1c3817d475bbe7d7df532fe1c4.zip
fix PR13339 (remove the predecessor from the unwind BB when removing an invoke)
llvm-svn: 160325
-rw-r--r--llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp1
-rw-r--r--llvm/test/Transforms/SimplifyCFG/invoke.ll22
2 files changed, 23 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
index 91158b429ea..99e236f5433 100644
--- a/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
+++ b/llvm/lib/Transforms/Scalar/SimplifyCFGPass.cpp
@@ -165,6 +165,7 @@ static bool MarkAliveBlocks(BasicBlock *BB,
if (II->use_empty() && II->onlyReadsMemory()) {
// jump to the normal destination branch.
BranchInst::Create(II->getNormalDest(), II);
+ II->getUnwindDest()->removePredecessor(II->getParent());
II->eraseFromParent();
} else
ChangeToCall(II);
diff --git a/llvm/test/Transforms/SimplifyCFG/invoke.ll b/llvm/test/Transforms/SimplifyCFG/invoke.ll
index ddced6b94df..10dc41b44bc 100644
--- a/llvm/test/Transforms/SimplifyCFG/invoke.ll
+++ b/llvm/test/Transforms/SimplifyCFG/invoke.ll
@@ -3,6 +3,7 @@ target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f3
declare i32 @__gxx_personality_v0(...)
declare void @__cxa_call_unexpected(i8*)
+declare void @purefn() nounwind readnone
declare i32 @read_only() nounwind readonly
declare i32 @nounwind_fn() nounwind
declare i32 @fn()
@@ -115,3 +116,24 @@ lpad:
tail call void @__cxa_call_unexpected(i8* %phi2) noreturn nounwind
unreachable
}
+
+; CHECK: @f6
+define void @f6() {
+entry:
+ invoke void @purefn()
+ to label %invoke.cont1 unwind label %lpad
+
+invoke.cont1:
+ %foo = invoke i32 @fn()
+ to label %invoke.cont2 unwind label %lpad
+
+invoke.cont2:
+ ret void
+
+lpad:
+; CHECK-NOT: phi
+ %tmp = phi i8* [ null, %invoke.cont1 ], [ null, %entry ]
+ landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ cleanup
+ ret void
+}
OpenPOWER on IntegriCloud