Don't DCE the landingpad instruction.
authorBill Wendling <isanbard@gmail.com>
Thu, 1 Sep 2011 01:16:58 +0000 (01:16 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 1 Sep 2011 01:16:58 +0000 (01:16 +0000)
The landingpad instruction can be removed only when its invokes are removed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138930 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstructionCombining.cpp

index 838678b9fab733bcef485585fa3ae4e4e0730482..4eea2ff3951f4f1a3b3eee4d359ac844bc00c8ee 100644 (file)
@@ -1577,6 +1577,11 @@ bool InstCombiner::DoOneIteration(Function &F, unsigned Iteration) {
         while (Term != BB->begin()) {   // Remove instrs bottom-up
           BasicBlock::iterator I = Term; --I;
 
+          // Don't remove the landingpad instruction. This should be removed
+          // only if its invokes are also removed.
+          if (isa<LandingPadInst>(I))
+            continue;
+
           DEBUG(errs() << "IC: DCE: " << *I << '\n');
           // A debug intrinsic shouldn't force another iteration if we weren't
           // going to do one without it.