From cfde9594d1ef63e5f45c24dcd76ab8d205482527 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 9 Apr 2007 16:41:46 +0000 Subject: [PATCH] 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 --- lib/Transforms/Scalar/LoopRotation.cpp | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/Transforms/Scalar/LoopRotation.cpp b/lib/Transforms/Scalar/LoopRotation.cpp index 21430d704fc..4fab1bf7c75 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(V)) - PN->addIncoming(V, NewPreHeader); - else { - RenameData *ILoopHeaderInfo = findReplacementData(cast(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(V) && + (ILoopHeaderInfo = findReplacementData(cast(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; -- 2.34.1