summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2012-04-18 06:00:09 +0000
committerBill Wendling <isanbard@gmail.com>2012-04-18 06:00:09 +0000
commit4d4d02575165600e9212c17275e0868f7f17fa1e (patch)
treee4602829a24b4a2f9d8cab08daa654965fed6b80 /llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
parentd274501180d1a1d04ccb6435d20aa2011456bcbd (diff)
downloadbcm5719-llvm-4d4d02575165600e9212c17275e0868f7f17fa1e.tar.gz
bcm5719-llvm-4d4d02575165600e9212c17275e0868f7f17fa1e.zip
Use a heavy hammer to fix PR12573.
If the loop contains invoke instructions, whose unwind edge escapes the loop, then don't try to unswitch the loop. Doing so may cause the unwind edge to be split, which not only is non-trivial but doesn't preserve loop simplify information. Fixes PR12573 llvm-svn: 154987
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopUnswitch.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/LoopUnswitch.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
index ee232687ffd..00ecc749af0 100644
--- a/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -409,6 +409,15 @@ bool LoopUnswitch::processCurrentLoop() {
if (!currentLoop->isSafeToClone())
return false;
+ // Loops with invokes, whose unwind edge escapes the loop, cannot be
+ // unswitched because splitting their edges are non-trivial and don't preserve
+ // loop simplify information.
+ for (Loop::block_iterator I = currentLoop->block_begin(),
+ E = currentLoop->block_end(); I != E; ++I)
+ if (const InvokeInst *II = dyn_cast<InvokeInst>((*I)->getTerminator()))
+ if (!currentLoop->contains(II->getUnwindDest()))
+ return false;
+
// Without dedicated exits, splitting the exit edge may fail.
if (!currentLoop->hasDedicatedExits())
return false;
OpenPOWER on IntegriCloud