[llvm-commits] [llvm] r154987 - /llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp

Bill Wendling isanbard at gmail.com
Tue Apr 17 23:00:09 PDT 2012


Author: void
Date: Wed Apr 18 01:00:09 2012
New Revision: 154987

URL: http://llvm.org/viewvc/llvm-project?rev=154987&view=rev
Log:
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

Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=154987&r1=154986&r2=154987&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Wed Apr 18 01:00:09 2012
@@ -409,6 +409,15 @@
   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;





More information about the llvm-commits mailing list