From 1708d1291633ed41a89caba8dc493203fdeaaa45 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 12 Apr 2004 05:15:13 +0000 Subject: [PATCH] Add support for removing invoke instructions git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@12858 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/GCSE.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Transforms/Scalar/GCSE.cpp b/lib/Transforms/Scalar/GCSE.cpp index bbefe8157f4..7db7d4dcde7 100644 --- a/lib/Transforms/Scalar/GCSE.cpp +++ b/lib/Transforms/Scalar/GCSE.cpp @@ -167,6 +167,13 @@ void GCSE::ReplaceInstructionWith(Instruction *I, Value *V) { // anything special. if (!isa(V)) { I->replaceAllUsesWith(V); + + if (InvokeInst *II = dyn_cast(I)) { + // Removing an invoke instruction requires adding a branch to the normal + // destination and removing PHI node entries in the exception destination. + new BranchInst(II->getNormalDest(), II); + II->getUnwindDest()->removePredecessor(II->getParent()); + } // Erase the instruction from the program. I->getParent()->getInstList().erase(I); @@ -179,6 +186,13 @@ void GCSE::ReplaceInstructionWith(Instruction *I, Value *V) { // Perform the replacement. I->replaceAllUsesWith(C); + if (InvokeInst *II = dyn_cast(I)) { + // Removing an invoke instruction requires adding a branch to the normal + // destination and removing PHI node entries in the exception destination. + new BranchInst(II->getNormalDest(), II); + II->getUnwindDest()->removePredecessor(II->getParent()); + } + // Erase the instruction from the program. I->getParent()->getInstList().erase(I); -- 2.34.1