summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/IPO/PruneEH.cpp3
-rw-r--r--llvm/test/Transforms/PruneEH/pr26263.ll26
2 files changed, 28 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/PruneEH.cpp b/llvm/lib/Transforms/IPO/PruneEH.cpp
index c2f55d896ba..22a95fa03f7 100644
--- a/llvm/lib/Transforms/IPO/PruneEH.cpp
+++ b/llvm/lib/Transforms/IPO/PruneEH.cpp
@@ -252,7 +252,8 @@ void PruneEH::DeleteBasicBlock(BasicBlock *BB) {
}
if (TokenInst) {
- changeToUnreachable(TokenInst->getNextNode(), /*UseLLVMTrap=*/false);
+ if (!isa<TerminatorInst>(TokenInst))
+ changeToUnreachable(TokenInst->getNextNode(), /*UseLLVMTrap=*/false);
} else {
// Get the list of successors of this block.
std::vector<BasicBlock *> Succs(succ_begin(BB), succ_end(BB));
diff --git a/llvm/test/Transforms/PruneEH/pr26263.ll b/llvm/test/Transforms/PruneEH/pr26263.ll
index 3670f00d811..17fafeb6850 100644
--- a/llvm/test/Transforms/PruneEH/pr26263.ll
+++ b/llvm/test/Transforms/PruneEH/pr26263.ll
@@ -27,4 +27,30 @@ cleanupret:
; CHECK: cleanupret from %[[cp]] unwind to caller
+define void @test2() personality i32 (...)* @__CxxFrameHandler3 {
+ invoke void @neverthrows()
+ to label %try.cont unwind label %catchswitch
+
+try.cont:
+ ret void
+
+catchswitch:
+ %cs = catchswitch within none [label %catchpad] unwind to caller
+
+catchpad:
+ %cp = catchpad within %cs []
+ unreachable
+
+ret:
+ ret void
+}
+
+; CHECK-LABEL: define void @test2(
+; CHECK: call void @neverthrows()
+
+; CHECK: %[[cs:.*]] = catchswitch within none [label
+
+; CHECK: catchpad within %[[cs]] []
+; CHECK-NEXT: unreachable
+
declare i32 @__CxxFrameHandler3(...)
OpenPOWER on IntegriCloud