[llvm] r251461 - [SimplifyCFG] Don't DCE catchret because the successor is unreachable

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 27 15:43:56 PDT 2015


Author: majnemer
Date: Tue Oct 27 17:43:56 2015
New Revision: 251461

URL: http://llvm.org/viewvc/llvm-project?rev=251461&view=rev
Log:
[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.

Modified:
    llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/trunk/test/Transforms/SimplifyCFG/wineh-unreachable.ll

Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=251461&r1=251460&r2=251461&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Tue Oct 27 17:43:56 2015
@@ -3178,8 +3178,7 @@ bool SimplifyCFGOpt::SimplifyUnreachable
                isa<CatchEndPadInst>(TI) || isa<TerminatePadInst>(TI)) {
       removeUnwindEdge(TI->getParent());
       Changed = true;
-    } else if (isa<CleanupReturnInst>(TI) || isa<CleanupEndPadInst>(TI) ||
-               isa<CatchReturnInst>(TI)) {
+    } else if (isa<CleanupReturnInst>(TI) || isa<CleanupEndPadInst>(TI)) {
       new UnreachableInst(TI->getContext(), TI);
       TI->eraseFromParent();
       Changed = true;

Modified: llvm/trunk/test/Transforms/SimplifyCFG/wineh-unreachable.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/wineh-unreachable.ll?rev=251461&r1=251460&r2=251461&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/wineh-unreachable.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/wineh-unreachable.ll Tue Oct 27 17:43:56 2015
@@ -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
+}




More information about the llvm-commits mailing list