fix PR5640 by tracking whether a block is the header of a loop more

precisely, which prevents us from infinitely peeling the loop.

llvm-svn: 90211
This commit is contained in:
Chris Lattner 2009-12-01 06:04:43 +00:00
parent 3a438a9336
commit 3c9aca9079
2 changed files with 29 additions and 3 deletions

View File

@ -158,12 +158,18 @@ bool JumpThreading::runOnFunction(Function &F) {
if (BBI->isTerminator()) {
// Since TryToSimplifyUncondBranchFromEmptyBlock may delete the
// block, we have to make sure it isn't in the LoopHeaders set. We
// reinsert afterward in the rare case when the block isn't deleted.
// reinsert afterward if needed.
bool ErasedFromLoopHeaders = LoopHeaders.erase(BB);
BasicBlock *Succ = BI->getSuccessor(0);
if (TryToSimplifyUncondBranchFromEmptyBlock(BB))
if (TryToSimplifyUncondBranchFromEmptyBlock(BB)) {
Changed = true;
else if (ErasedFromLoopHeaders)
// If we deleted BB and BB was the header of a loop, then the
// successor is now the header of the loop.
BB = Succ;
}
if (ErasedFromLoopHeaders)
LoopHeaders.insert(BB);
}
}

View File

@ -192,3 +192,23 @@ bb61:
ret void
}
; PR5640
define fastcc void @test6(i1 %tmp, i1 %tmp1) nounwind ssp {
entry:
br i1 %tmp, label %bb12, label %bb14
bb12:
br label %bb14
bb14:
%A = phi i1 [ %A, %bb13 ], [ true, %bb12 ], [%tmp1, %entry]
br label %bb13
bb13:
br i1 %A, label %bb14, label %bb61
bb61:
ret void
}