summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LowerInvoke.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-08-03 18:51:44 +0000
committerChris Lattner <sabre@nondot.org>2005-08-03 18:51:44 +0000
commit3de05cc93019c2ed86b1353316a15dd89c1432ec (patch)
tree17d6a90bdc0fd6e9ec22ca31223008b4a64d62d1 /llvm/lib/Transforms/Scalar/LowerInvoke.cpp
parentc519a7e06e4acef879402cd70b980a83c3db42a8 (diff)
downloadbcm5719-llvm-3de05cc93019c2ed86b1353316a15dd89c1432ec.tar.gz
bcm5719-llvm-3de05cc93019c2ed86b1353316a15dd89c1432ec.zip
The correct fix for PR612, which also fixes
Transforms/LowerInvoke/2005-08-03-InvokeWithPHIUse.ll llvm-svn: 22628
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LowerInvoke.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LowerInvoke.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/LowerInvoke.cpp b/llvm/lib/Transforms/Scalar/LowerInvoke.cpp
index 96d5b98c6bd..b0d8fb8a308 100644
--- a/llvm/lib/Transforms/Scalar/LowerInvoke.cpp
+++ b/llvm/lib/Transforms/Scalar/LowerInvoke.cpp
@@ -283,10 +283,20 @@ bool LowerInvoke::insertExpensiveEHSupport(Function &F) {
// Create the receiver block if there is a critical edge to the normal
// destination.
SplitCriticalEdge(II, 0, this);
- BasicBlock::iterator InsertLoc = II->getNormalDest()->begin();
- while (isa<PHINode>(InsertLoc)) ++InsertLoc;
+ // There should not be any PHI nodes in II->getNormalDest() now. It has
+ // a single predecessor, so any PHI nodes are unneeded. Remove them now
+ // by replacing them with their single input value.
+ assert(II->getNormalDest()->getSinglePredecessor() &&
+ "Split crit edge doesn't have a single predecessor!");
+ BasicBlock::iterator InsertLoc = II->getNormalDest()->begin();
+ while (PHINode *PN = dyn_cast<PHINode>(InsertLoc)) {
+ PN->replaceAllUsesWith(PN->getIncomingValue(0));
+ PN->eraseFromParent();
+ InsertLoc = II->getNormalDest()->begin();
+ }
+
// Insert a normal call instruction on the normal execution path.
std::string Name = II->getName(); II->setName("");
CallInst *NewCall = new CallInst(II->getCalledValue(),
OpenPOWER on IntegriCloud