diff options
author | Devang Patel <dpatel@apple.com> | 2007-04-09 16:41:46 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2007-04-09 16:41:46 +0000 |
commit | cfde9594d1ef63e5f45c24dcd76ab8d205482527 (patch) | |
tree | 7b1d23fa47b0c5b4f2e99dcfadf7cbc316e04179 /lib/Transforms | |
parent | 24a1c49172b7572652492ca986d49715ac1435ea (diff) |
Fix future bug. Of course, Chris spotted this.
Handle Argument or Undef as an incoming PHI value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35821 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/LoopRotation.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/Transforms/Scalar/LoopRotation.cpp b/lib/Transforms/Scalar/LoopRotation.cpp index 21430d704f..4fab1bf7c7 100644 --- a/lib/Transforms/Scalar/LoopRotation.cpp +++ b/lib/Transforms/Scalar/LoopRotation.cpp @@ -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,20 +381,22 @@ 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() { L = NULL; |