aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-04-25 00:54:58 +0000
committerChris Lattner <sabre@nondot.org>2003-04-25 00:54:58 +0000
commitc8789cb40b81d032b79e02023e025d3ca7711365 (patch)
treee340b665fd9ba513ed1cac311b8e8a8938813e39 /lib/Transforms/Utils/PromoteMemoryToRegister.cpp
parent5f73e38548c57636ad0ef8c719d040e166761962 (diff)
Fix bug: mem2reg/2003-04-24-MultipleIdenticalSuccessors.ll
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5919 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils/PromoteMemoryToRegister.cpp')
-rw-r--r--lib/Transforms/Utils/PromoteMemoryToRegister.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
index 3378369f7a..85acce66e1 100644
--- a/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
+++ b/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
@@ -222,13 +222,14 @@ void PromoteMem2Reg::RenamePass(BasicBlock *BB, BasicBlock *Pred,
std::vector<PHINode *> &BBPNs = NewPhiNodes[BB];
for (unsigned k = 0; k != BBPNs.size(); ++k)
if (PHINode *PN = BBPNs[k]) {
- int BBI = PN->getBasicBlockIndex(Pred);
- assert(BBI >= 0 && "Predecessor not in basic block yet!");
-
- // At this point we can assume that the array has phi nodes.. let's update
- // the incoming data.
- PN->setIncomingValue(BBI, IncomingVals[k]);
-
+ // The PHI node may have multiple entries for this predecessor. We must
+ // make sure we update all of them.
+ for (unsigned i = 0, e = PN->getNumOperands(); i != e; i += 2) {
+ if (PN->getOperand(i+1) == Pred)
+ // At this point we can assume that the array has phi nodes.. let's
+ // update the incoming data.
+ PN->setOperand(i, IncomingVals[k]);
+ }
// also note that the active variable IS designated by the phi node
IncomingVals[k] = PN;
}