From 1d1a2976d5a49a4243d1b1add919edc6d8ba1430 Mon Sep 17 00:00:00 2001 From: David Majnemer Date: Tue, 27 Oct 2015 22:43:56 +0000 Subject: [PATCH] [SimplifyCFG] Don't DCE catchret because the successor is unreachable CatchReturnInst has side-effects: it runs a destructor. This destructor could conceivably run forever/call exit/etc. and should not be removed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251461 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Utils/SimplifyCFG.cpp | 3 +-- .../SimplifyCFG/wineh-unreachable.ll | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index e435537c3a7..69c08e55283 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -3178,8 +3178,7 @@ bool SimplifyCFGOpt::SimplifyUnreachable(UnreachableInst *UI) { isa(TI) || isa(TI)) { removeUnwindEdge(TI->getParent()); Changed = true; - } else if (isa(TI) || isa(TI) || - isa(TI)) { + } else if (isa(TI) || isa(TI)) { new UnreachableInst(TI->getContext(), TI); TI->eraseFromParent(); Changed = true; diff --git a/test/Transforms/SimplifyCFG/wineh-unreachable.ll b/test/Transforms/SimplifyCFG/wineh-unreachable.ll index 7db883b2412..31d567f6492 100644 --- a/test/Transforms/SimplifyCFG/wineh-unreachable.ll +++ b/test/Transforms/SimplifyCFG/wineh-unreachable.ll @@ -86,3 +86,23 @@ unreachable.unwind: cleanuppad [] unreachable } + +; CHECK-LABEL: define void @test5() +define void @test5() personality i8* bitcast (void ()* @Personality to i8*) { +entry: + invoke void @f() + to label %exit unwind label %catch.pad + +catch.pad: + %catch = catchpad [] + to label %catch.body unwind label %catch.end + +catch.body: + catchret %catch to label %exit + +catch.end: + catchendpad unwind to caller + +exit: + unreachable +} -- 2.34.1