summaryrefslogtreecommitdiff
path: root/lib/Transforms/IPO
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-09-20 22:27:16 +0000
committerBill Wendling <isanbard@gmail.com>2011-09-20 22:27:16 +0000
commitb7e807f9a9a74d743547856c4275a320f7b5b15e (patch)
treea7458d3e34dd783d04addda5b8626a3a5b313852 /lib/Transforms/IPO
parente4b3ef43e1460f98c5c4daaba7e10644026e5939 (diff)
downloadllvm-b7e807f9a9a74d743547856c4275a320f7b5b15e.tar.gz
llvm-b7e807f9a9a74d743547856c4275a320f7b5b15e.tar.bz2
llvm-b7e807f9a9a74d743547856c4275a320f7b5b15e.tar.xz
Place the check for an exit landing pad where it will be run on both code paths through the if-then-else.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@140195 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r--lib/Transforms/IPO/LoopExtractor.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/lib/Transforms/IPO/LoopExtractor.cpp b/lib/Transforms/IPO/LoopExtractor.cpp
index 826ade38d1..4f96afe44c 100644
--- a/lib/Transforms/IPO/LoopExtractor.cpp
+++ b/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;