[llvm] r258616 - [PruneEH] Don't try to insert a terminator after another terminator
David Majnemer via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 22 22:00:44 PST 2016
Author: majnemer
Date: Sat Jan 23 00:00:44 2016
New Revision: 258616
URL: http://llvm.org/viewvc/llvm-project?rev=258616&view=rev
Log:
[PruneEH] Don't try to insert a terminator after another terminator
LLVM's BasicBlock has a single terminator, it is not valid to have two.
Modified:
llvm/trunk/lib/Transforms/IPO/PruneEH.cpp
llvm/trunk/test/Transforms/PruneEH/pr26263.ll
Modified: llvm/trunk/lib/Transforms/IPO/PruneEH.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/PruneEH.cpp?rev=258616&r1=258615&r2=258616&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/PruneEH.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/PruneEH.cpp Sat Jan 23 00:00:44 2016
@@ -252,7 +252,8 @@ void PruneEH::DeleteBasicBlock(BasicBloc
}
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));
Modified: llvm/trunk/test/Transforms/PruneEH/pr26263.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/PruneEH/pr26263.ll?rev=258616&r1=258615&r2=258616&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/PruneEH/pr26263.ll (original)
+++ llvm/trunk/test/Transforms/PruneEH/pr26263.ll Sat Jan 23 00:00:44 2016
@@ -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(...)
More information about the llvm-commits
mailing list