diff options
author | Bill Wendling <isanbard@gmail.com> | 2011-09-20 22:27:16 +0000 |
---|---|---|
committer | Bill Wendling <isanbard@gmail.com> | 2011-09-20 22:27:16 +0000 |
commit | 04289fcad89c76f52e7769b96586dffc00025b63 (patch) | |
tree | eb84d29465ed204b88460965c31af611211a2366 /llvm/lib/Transforms/IPO/LoopExtractor.cpp | |
parent | 818584529ec530f7cdec7ab3a736a244f24090d8 (diff) | |
download | bcm5719-llvm-04289fcad89c76f52e7769b96586dffc00025b63.tar.gz bcm5719-llvm-04289fcad89c76f52e7769b96586dffc00025b63.zip |
Place the check for an exit landing pad where it will be run on both code paths through the if-then-else.
llvm-svn: 140195
Diffstat (limited to 'llvm/lib/Transforms/IPO/LoopExtractor.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/LoopExtractor.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/llvm/lib/Transforms/IPO/LoopExtractor.cpp b/llvm/lib/Transforms/IPO/LoopExtractor.cpp index 826ade38d1e..4f96afe44c0 100644 --- a/llvm/lib/Transforms/IPO/LoopExtractor.cpp +++ b/llvm/lib/Transforms/IPO/LoopExtractor.cpp @@ -105,21 +105,30 @@ bool LoopExtractor::runOnLoop(Loop *L, LPPassManager &LPM) { ShouldExtractLoop = true; } else { // Check to see if any exits from the loop are more than just return - // blocks. We also must omit landing pads. Landing pads must accompany the - // invoke instruction. But this would result in a loop in the extracted + // blocks. + SmallVector<BasicBlock*, 8> ExitBlocks; + L->getExitBlocks(ExitBlocks); + for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) + if (!isa<ReturnInst>(ExitBlocks[i]->getTerminator())) { + ShouldExtractLoop = true; + break; + } + } + + if (ShouldExtractLoop) { + // We 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())) - ShouldExtractLoop = true; + for (unsigned i = 0, e = ExitBlocks.size(); i != e; ++i) if (ExitBlocks[i]->isLandingPad()) { ShouldExtractLoop = false; break; } - } } + if (ShouldExtractLoop) { if (NumLoops == 0) return Changed; --NumLoops; |