diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2008-03-09 05:04:48 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2008-03-09 05:04:48 +0000 |
commit | cc24104703079a28636eb9994c66711ecc73ab88 (patch) | |
tree | 9b4cd007ee489623c0d3ba4aac990a6571f511e3 /llvm/lib | |
parent | 4d0ed842b1495c68f2ad592ae790b0fecabcb43f (diff) | |
download | bcm5719-llvm-cc24104703079a28636eb9994c66711ecc73ab88.tar.gz bcm5719-llvm-cc24104703079a28636eb9994c66711ecc73ab88.zip |
Two things. Preserve the unwind_to when splitting a BB.
Add the ability to remove just one instance of a BB from a phi node. This fixes
the compile error in the tree now.
llvm-svn: 48085
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Utils/BasicBlockUtils.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/VMCore/BasicBlock.cpp | 19 |
2 files changed, 14 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp index 3607237e41d..0dc38a2b84a 100644 --- a/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp +++ b/llvm/lib/Transforms/Utils/BasicBlockUtils.cpp @@ -160,6 +160,7 @@ BasicBlock *llvm::SplitBlock(BasicBlock *Old, Instruction *SplitPt, Pass *P) { while (isa<PHINode>(SplitIt)) ++SplitIt; BasicBlock *New = Old->splitBasicBlock(SplitIt, Old->getName()+".split"); + New->setUnwindDest(Old->getUnwindDest()); // The new block lives in whichever loop the old one did. if (Loop *L = LI.getLoopFor(Old)) diff --git a/llvm/lib/VMCore/BasicBlock.cpp b/llvm/lib/VMCore/BasicBlock.cpp index f9bead74d25..1288fdf32c4 100644 --- a/llvm/lib/VMCore/BasicBlock.cpp +++ b/llvm/lib/VMCore/BasicBlock.cpp @@ -188,14 +188,12 @@ BasicBlock *BasicBlock::getSinglePredecessor() { /// called while the predecessor still refers to this block. /// void BasicBlock::removePredecessor(BasicBlock *Pred, - bool DontDeleteUselessPHIs) { + bool DontDeleteUselessPHIs, + bool OnlyDeleteOne) { assert((hasNUsesOrMore(16)||// Reduce cost of this assertion for complex CFGs. find(pred_begin(this), pred_end(this), Pred) != pred_end(this)) && "removePredecessor: BB is not a predecessor!"); - if (Pred == getUnwindDest()) - setUnwindDest(NULL); - if (InstList.empty()) return; PHINode *APN = dyn_cast<PHINode>(&front()); if (!APN) return; // Quick exit. @@ -226,7 +224,11 @@ void BasicBlock::removePredecessor(BasicBlock *Pred, // Yup, loop through and nuke the PHI nodes while (PHINode *PN = dyn_cast<PHINode>(&front())) { // Remove the predecessor first. - PN->removeIncomingValue(Pred, !DontDeleteUselessPHIs); + if (OnlyDeleteOne) { + int idx = PN->getBasicBlockIndex(Pred); + PN->removeIncomingValue(idx, !DontDeleteUselessPHIs); + } else + PN->removeIncomingValue(Pred, !DontDeleteUselessPHIs); // If the PHI _HAD_ two uses, replace PHI node with its now *single* value if (max_idx == 2) { @@ -247,7 +249,12 @@ void BasicBlock::removePredecessor(BasicBlock *Pred, PHINode *PN; for (iterator II = begin(); (PN = dyn_cast<PHINode>(II)); ) { ++II; - PN->removeIncomingValue(Pred, false); + if (OnlyDeleteOne) { + int idx = PN->getBasicBlockIndex(Pred); + PN->removeIncomingValue(idx, false); + } else + PN->removeIncomingValue(Pred, false); + // If all incoming values to the Phi are the same, we can replace the Phi // with that value. Value* PNV = 0; |