summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2011-08-17 21:20:43 +0000
committerBill Wendling <isanbard@gmail.com>2011-08-17 21:20:43 +0000
commit39257d6b5c5a70cf2a4fe2d75150de1fce0b585d (patch)
treedf98f792a39ae601226dc44f185eb7fe247724f0 /llvm/lib/Transforms
parent897af91e1a15e3e284861bef754b3d9eddb52129 (diff)
downloadbcm5719-llvm-39257d6b5c5a70cf2a4fe2d75150de1fce0b585d.tar.gz
bcm5719-llvm-39257d6b5c5a70cf2a4fe2d75150de1fce0b585d.zip
Don't optimize the landing pad exit block.
One way to exit the loop is through an unwind edge. However, that may involve splitting the critical edge of the landing pad, which is non-trivial. Prevent the transformation from rewriting the landing pad exit loop block. llvm-svn: 137871
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/Utils/LoopSimplify.cpp22
1 files changed, 18 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopSimplify.cpp b/llvm/lib/Transforms/Utils/LoopSimplify.cpp
index 6a9976930c9..b0196840213 100644
--- a/llvm/lib/Transforms/Utils/LoopSimplify.cpp
+++ b/llvm/lib/Transforms/Utils/LoopSimplify.cpp
@@ -398,6 +398,9 @@ BasicBlock *LoopSimplify::InsertPreheaderForLoop(Loop *L) {
/// blocks. This method is used to split exit blocks that have predecessors
/// outside of the loop.
BasicBlock *LoopSimplify::RewriteLoopExitBlock(Loop *L, BasicBlock *Exit) {
+ // Don't split a landing pad block.
+ if (Exit->isLandingPad()) return 0;
+
SmallVector<BasicBlock*, 8> LoopBlocks;
for (pred_iterator I = pred_begin(Exit), E = pred_end(Exit); I != E; ++I) {
BasicBlock *P = *I;
@@ -746,18 +749,29 @@ void LoopSimplify::verifyAnalysis() const {
(void)HasIndBrPred;
}
- // Indirectbr can interfere with exit block canonicalization.
+ // Indirectbr and LandingPad can interfere with exit block canonicalization.
if (!L->hasDedicatedExits()) {
bool HasIndBrExiting = false;
+ bool HasLPadExiting = false;
SmallVector<BasicBlock*, 8> ExitingBlocks;
L->getExitingBlocks(ExitingBlocks);
- for (unsigned i = 0, e = ExitingBlocks.size(); i != e; ++i)
+ for (unsigned i = 0, e = ExitingBlocks.size(); i != e; ++i) {
if (isa<IndirectBrInst>((ExitingBlocks[i])->getTerminator())) {
HasIndBrExiting = true;
break;
}
- assert(HasIndBrExiting &&
+ if (const InvokeInst *II =
+ dyn_cast<InvokeInst>(ExitingBlocks[i]->getTerminator())) {
+ if (L->contains(II->getNormalDest()) &&
+ !L->contains(II->getUnwindDest())) {
+ HasLPadExiting = true;
+ break;
+ }
+ }
+ }
+
+ assert((HasIndBrExiting || HasLPadExiting) &&
"LoopSimplify has no excuse for missing exit block info!");
- (void)HasIndBrExiting;
+ (void)HasIndBrExiting; (void)HasLPadExiting;
}
}
OpenPOWER on IntegriCloud