mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-27 14:34:58 +00:00
fix PR5640 by tracking whether a block is the header of a loop more
precisely, which prevents us from infinitely peeling the loop. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@90211 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
18518603f1
commit
46875c0bfb
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user