[llvm] r247710 - [ShrinkWrapping] Fix an infinite loop while looking for restore point.
Quentin Colombet via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 15 11:19:39 PDT 2015
Author: qcolombet
Date: Tue Sep 15 13:19:39 2015
New Revision: 247710
URL: http://llvm.org/viewvc/llvm-project?rev=247710&view=rev
Log:
[ShrinkWrapping] Fix an infinite loop while looking for restore point.
This may happen when the input program itself contains an infinite loop with no
exit block. In that case, we would fail to find a block post-dominating the loop
such that this block is outside of the loop.
This fixes PR24823.
Working on reducing the test case.
Modified:
llvm/trunk/lib/CodeGen/ShrinkWrap.cpp
Modified: llvm/trunk/lib/CodeGen/ShrinkWrap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ShrinkWrap.cpp?rev=247710&r1=247709&r2=247710&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/ShrinkWrap.cpp (original)
+++ llvm/trunk/lib/CodeGen/ShrinkWrap.cpp Tue Sep 15 13:19:39 2015
@@ -309,6 +309,14 @@ void ShrinkWrap::updateSaveRestorePoints
}
}
else {
+ // If the loop does not exit, there is no point in looking
+ // for a post-dominator outside the loop.
+ SmallVector<MachineBasicBlock*, 4> ExitBlocks;
+ MLI->getLoopFor(Restore)->getExitingBlocks(ExitBlocks);
+ if (ExitBlocks.empty()) {
+ Restore = nullptr;
+ break;
+ }
// Push Restore outside of this loop if immediate post-dominator is
// different from restore block. If immediate post-dominator is not
// different, bail out.
More information about the llvm-commits
mailing list