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
This commit is contained in:
Chris Lattner 2003-04-25 00:54:58 +00:00
parent 5f73e38548
commit c8789cb40b

View File

@ -222,13 +222,14 @@ void PromoteMem2Reg::RenamePass(BasicBlock *BB, BasicBlock *Pred,
std::vector<PHINode *> &BBPNs = NewPhiNodes[BB]; std::vector<PHINode *> &BBPNs = NewPhiNodes[BB];
for (unsigned k = 0; k != BBPNs.size(); ++k) for (unsigned k = 0; k != BBPNs.size(); ++k)
if (PHINode *PN = BBPNs[k]) { if (PHINode *PN = BBPNs[k]) {
int BBI = PN->getBasicBlockIndex(Pred); // The PHI node may have multiple entries for this predecessor. We must
assert(BBI >= 0 && "Predecessor not in basic block yet!"); // make sure we update all of them.
for (unsigned i = 0, e = PN->getNumOperands(); i != e; i += 2) {
// At this point we can assume that the array has phi nodes.. let's update if (PN->getOperand(i+1) == Pred)
// the incoming data. // At this point we can assume that the array has phi nodes.. let's
PN->setIncomingValue(BBI, IncomingVals[k]); // update the incoming data.
PN->setOperand(i, IncomingVals[k]);
}
// also note that the active variable IS designated by the phi node // also note that the active variable IS designated by the phi node
IncomingVals[k] = PN; IncomingVals[k] = PN;
} }