From: Bill Wendling Date: Wed, 18 Apr 2012 06:00:09 +0000 (+0000) Subject: Use a heavy hammer to fix PR12573. X-Git-Tag: android-x86-6.0-r1~231^2~38 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=135604129646650ef9abcd12a38b2d8976d3493c;p=android-x86%2Fexternal-llvm.git 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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154987 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp index ee232687ffd..00ecc749af0 100644 --- a/lib/Transforms/Scalar/LoopUnswitch.cpp +++ b/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((*I)->getTerminator())) + if (!currentLoop->contains(II->getUnwindDest())) + return false; + // Without dedicated exits, splitting the exit edge may fail. if (!currentLoop->hasDedicatedExits()) return false;