Fix future bug. Of course, Chris spotted this.

Handle Argument or Undef as an incoming PHI value.

llvm-svn: 35821
This commit is contained in:
Devang Patel 2007-04-09 16:41:46 +00:00
parent b28a391a8d
commit d6ba41e02d
1 changed files with 12 additions and 11 deletions

View File

@ -369,7 +369,6 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) {
return true;
}
/// Make sure all Exit block PHINodes have required incoming values.
/// If incoming value is constant or defined outside the loop then
/// PHINode may not have an entry for new pre-header.
@ -382,19 +381,21 @@ void LoopRotate::updateExitBlock() {
if (!PN)
break;
if (PN->getBasicBlockIndex(NewPreHeader) == -1) {
Value *V = PN->getIncomingValueForBlock(OrigHeader);
if (isa<Constant>(V))
PN->addIncoming(V, NewPreHeader);
else {
RenameData *ILoopHeaderInfo = findReplacementData(cast<Instruction>(V));
assert (ILoopHeaderInfo && ILoopHeaderInfo->PreHeader && "Missing New Preheader Instruction");
PN->addIncoming(ILoopHeaderInfo->PreHeader, NewPreHeader);
}
}
}
}
// There is already one incoming value from new pre-header block.
if (PN->getBasicBlockIndex(NewPreHeader) != -1)
return;
RenameData *ILoopHeaderInfo;
Value *V = PN->getIncomingValueForBlock(OrigHeader);
if (isa<Instruction>(V) &&
(ILoopHeaderInfo = findReplacementData(cast<Instruction>(V)))) {
assert (ILoopHeaderInfo->PreHeader && "Missing New Preheader Instruction");
PN->addIncoming(ILoopHeaderInfo->PreHeader, NewPreHeader);
} else {
PN->addIncoming(V, NewPreHeader);
}
}
}
/// Initialize local data
void LoopRotate::initialize() {