mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 16:24:23 +00:00
LSR fix: Add isSimplifiedLoopNest to IVUsers analysis.
Only record IVUsers that are dominated by simplified loop headers. Otherwise SCEVExpander will crash while looking for a preheader. I previously tried to work around this in LSR itself, but that was insufficient. This way, LSR can continue to run if some uses are not in simple loops, as long as we don't attempt to analyze those users. Fixes <rdar://problem/11049788> Segmentation fault: 11 in LoopStrengthReduce git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152892 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -4534,22 +4534,25 @@ LSRInstance::LSRInstance(const TargetLowering *tli, Loop *l, Pass *P)
|
||||
if (!L->isLoopSimplifyForm())
|
||||
return;
|
||||
|
||||
// If there's no interesting work to be done, bail early.
|
||||
if (IU.empty()) return;
|
||||
|
||||
#ifndef NDEBUG
|
||||
// All dominating loops must have preheaders, or SCEVExpander may not be able
|
||||
// to materialize an AddRecExpr whose Start is an outer AddRecExpr.
|
||||
//
|
||||
// FIXME: This is a little absurd. I think LoopSimplify should be taught
|
||||
// to create a preheader under any circumstance.
|
||||
// IVUsers analysis should only create users that are dominated by simple loop
|
||||
// headers. Since this loop should dominate all of its users, its user list
|
||||
// should be empty if this loop itself is not within a simple loop nest.
|
||||
for (DomTreeNode *Rung = DT.getNode(L->getLoopPreheader());
|
||||
Rung; Rung = Rung->getIDom()) {
|
||||
BasicBlock *BB = Rung->getBlock();
|
||||
const Loop *DomLoop = LI.getLoopFor(BB);
|
||||
if (DomLoop && DomLoop->getHeader() == BB) {
|
||||
if (!DomLoop->getLoopPreheader())
|
||||
return;
|
||||
assert(DomLoop->getLoopPreheader() && "LSR needs a simplified loop nest");
|
||||
}
|
||||
}
|
||||
// If there's no interesting work to be done, bail early.
|
||||
if (IU.empty()) return;
|
||||
#endif // DEBUG
|
||||
|
||||
DEBUG(dbgs() << "\nLSR on loop ";
|
||||
WriteAsOperand(dbgs(), L->getHeader(), /*PrintType=*/false);
|
||||
|
Reference in New Issue
Block a user