diff options
author | Bill Wendling <isanbard@gmail.com> | 2011-09-20 22:23:09 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2011-09-20 22:23:09 +0000 |
commit | 84b6706d9003f6078a81ed7d84f4e49ee70f7ef8 (patch) | |
tree | cf6a4a6c2ae0c9de1576c79961d36f4003936933 /lib/Transforms/IPO | |
parent | aabc6a9b79b179e7a69dd78900dcd05215977112 (diff) | |
download | external_llvm-84b6706d9003f6078a81ed7d84f4e49ee70f7ef8.zip external_llvm-84b6706d9003f6078a81ed7d84f4e49ee70f7ef8.tar.gz external_llvm-84b6706d9003f6078a81ed7d84f4e49ee70f7ef8.tar.bz2 |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140193 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r-- | lib/Transforms/IPO/LoopExtractor.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/Transforms/IPO/LoopExtractor.cpp b/lib/Transforms/IPO/LoopExtractor.cpp index 714282b..826ade3 100644 --- a/lib/Transforms/IPO/LoopExtractor.cpp +++ b/lib/Transforms/IPO/LoopExtractor.cpp @@ -101,18 +101,24 @@ bool LoopExtractor::runOnLoop(Loop *L, LPPassManager &LPM) { 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; |