[llvm-commits] [llvm] r140193 - /llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp
Bill Wendling
isanbard at gmail.com
Tue Sep 20 15:23:09 PDT 2011
Author: void
Date: Tue Sep 20 17:23:09 2011
New Revision: 140193
URL: http://llvm.org/viewvc/llvm-project?rev=140193&view=rev
Log:
Omit extracting a loop if one of the exits is a landing pad.
The landing pad must accompany the invoke when it's extracted. However, if it
does, then the loop isn't properly extracted. I.e., the resulting extraction has
a loop in it. The extracted function is then extracted, etc. resulting in an
infinite loop.
Modified:
llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp
Modified: llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp?rev=140193&r1=140192&r2=140193&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp Tue Sep 20 17:23:09 2011
@@ -101,18 +101,24 @@
L->getHeader()->getParent()->getEntryBlock().getTerminator();
if (!isa<BranchInst>(EntryTI) ||
!cast<BranchInst>(EntryTI)->isUnconditional() ||
- EntryTI->getSuccessor(0) != L->getHeader())
+ EntryTI->getSuccessor(0) != L->getHeader()) {
ShouldExtractLoop = true;
- else {
+ } else {
// Check to see if any exits from the loop are more than just return
- // blocks.
+ // blocks. We also must omit landing pads. Landing pads must accompany the
+ // invoke instruction. But this would result in a loop in the extracted
+ // function. An infinite cycle occurs when it tries to extract that loop as
+ // well.
SmallVector<BasicBlock*, 8> ExitBlocks;
L->getExitBlocks(ExitBlocks);
- for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i)
- if (!isa<ReturnInst>(ExitBlocks[i]->getTerminator())) {
+ for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) {
+ if (!isa<ReturnInst>(ExitBlocks[i]->getTerminator()))
ShouldExtractLoop = true;
+ if (ExitBlocks[i]->isLandingPad()) {
+ ShouldExtractLoop = false;
break;
}
+ }
}
if (ShouldExtractLoop) {
if (NumLoops == 0) return Changed;
More information about the llvm-commits
mailing list