[llvm-commits] CVS: llvm/lib/Transforms/Scalar/LowerInvoke.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Aug 3 11:51:55 PDT 2005
Changes in directory llvm/lib/Transforms/Scalar:
LowerInvoke.cpp updated: 1.27 -> 1.28
---
Log message:
The correct fix for PR612: http://llvm.cs.uiuc.edu/PR612 , which also fixes
Transforms/LowerInvoke/2005-08-03-InvokeWithPHIUse.ll
---
Diffs of the changes: (+12 -2)
LowerInvoke.cpp | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
Index: llvm/lib/Transforms/Scalar/LowerInvoke.cpp
diff -u llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.27 llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.28
--- llvm/lib/Transforms/Scalar/LowerInvoke.cpp:1.27 Wed Aug 3 13:34:29 2005
+++ llvm/lib/Transforms/Scalar/LowerInvoke.cpp Wed Aug 3 13:51:44 2005
@@ -283,10 +283,20 @@
// 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(),
More information about the llvm-commits
mailing list