Reapply r198478 "Fix PR18361: Invalidate LoopDispositions after LoopSimplify hoists things."

Now with a fix for PR18384: ValueHandleBase::ValueIsDeleted.

We need to invalidate SCEV's loop info when we delete a block, even if no values are hoisted.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@198631 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Andrew Trick
2014-01-06 19:43:14 +00:00
parent 1abc3c0b7f
commit a55aaf7fe6
4 changed files with 211 additions and 7 deletions

View File

@@ -309,6 +309,7 @@ ReprocessLoop:
// Attempt to hoist out all instructions except for the
// comparison and the branch.
bool AllInvariant = true;
bool AnyInvariant = false;
for (BasicBlock::iterator I = ExitingBlock->begin(); &*I != BI; ) {
Instruction *Inst = I++;
// Skip debug info intrinsics.
@@ -316,12 +317,19 @@ ReprocessLoop:
continue;
if (Inst == CI)
continue;
if (!L->makeLoopInvariant(Inst, Changed,
Preheader ? Preheader->getTerminator() : 0)) {
if (!L->makeLoopInvariant(Inst, AnyInvariant,
Preheader ? Preheader->getTerminator() : 0)) {
AllInvariant = false;
break;
}
}
if (AnyInvariant) {
Changed = true;
// The loop disposition of all SCEV expressions that depend on any
// hoisted values have also changed.
if (SE)
SE->forgetLoopDispositions(L);
}
if (!AllInvariant) continue;
// The block has now been cleared of all instructions except for
@@ -334,11 +342,10 @@ ReprocessLoop:
DEBUG(dbgs() << "LoopSimplify: Eliminating exiting block "
<< ExitingBlock->getName() << "\n");
// If any reachable control flow within this loop has changed, notify
// ScalarEvolution. Currently assume the parent loop doesn't change
// (spliting edges doesn't count). If blocks, CFG edges, or other values
// in the parent loop change, then we need call to forgetLoop() for the
// parent instead.
// Notify ScalarEvolution before deleting this block. Currently assume the
// parent loop doesn't change (spliting edges doesn't count). If blocks,
// CFG edges, or other values in the parent loop change, then we need call
// to forgetLoop() for the parent instead.
if (SE)
SE->forgetLoop(L);