summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/BasicBlock.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-02-25 00:35:07 +0000
committerChris Lattner <sabre@nondot.org>2002-02-25 00:35:07 +0000
commit4eed0b8390b0297aa55220e1debf10861966bca6 (patch)
treeed3f12befd416158a2b5b8af3c7cb13502ad69b7 /llvm/lib/VMCore/BasicBlock.cpp
parent28aa0c17a3ed939fb30ecb6241a3c0e359034a91 (diff)
downloadbcm5719-llvm-4eed0b8390b0297aa55220e1debf10861966bca6.tar.gz
bcm5719-llvm-4eed0b8390b0297aa55220e1debf10861966bca6.zip
Fix bug: test/Regression/Other/2002-02-24-InlineBrokePHINodes.ll
llvm-svn: 1798
Diffstat (limited to 'llvm/lib/VMCore/BasicBlock.cpp')
-rw-r--r--llvm/lib/VMCore/BasicBlock.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/llvm/lib/VMCore/BasicBlock.cpp b/llvm/lib/VMCore/BasicBlock.cpp
index 222bb140193..45ae72bc1e0 100644
--- a/llvm/lib/VMCore/BasicBlock.cpp
+++ b/llvm/lib/VMCore/BasicBlock.cpp
@@ -155,5 +155,25 @@ BasicBlock *BasicBlock::splitBasicBlock(iterator I) {
// Add a branch instruction to the newly formed basic block.
InstList.push_back(new BranchInst(New));
+
+ // Now we must loop through all of the successors of the New block (which
+ // _were_ the successors of the 'this' block), and update any PHI nodes in
+ // successors. If there were PHI nodes in the successors, then they need to
+ // know that incoming branches will be from New, not from Old.
+ //
+ for (BasicBlock::succ_iterator I = succ_begin(New), E = succ_end(New);
+ I != E; ++I) {
+ // Loop over any phi nodes in the basic block, updating the BB field of
+ // incoming values...
+ BasicBlock *Successor = *I;
+ for (BasicBlock::iterator II = Successor->begin();
+ PHINode *PN = dyn_cast<PHINode>(*II); ++II) {
+ int IDX = PN->getBasicBlockIndex(this);
+ while (IDX != -1) {
+ PN->setIncomingBlock((unsigned)IDX, New);
+ IDX = PN->getBasicBlockIndex(this);
+ }
+ }
+ }
return New;
}
OpenPOWER on IntegriCloud