[llvm-commits] [llvm] r140195 - /llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp

Bill Wendling isanbard at gmail.com
Tue Sep 20 15:27:16 PDT 2011


Author: void
Date: Tue Sep 20 17:27:16 2011
New Revision: 140195

URL: http://llvm.org/viewvc/llvm-project?rev=140195&view=rev
Log:
Place the check for an exit landing pad where it will be run on both code paths through the if-then-else.

Modified:
    llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp

Modified: llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp?rev=140195&r1=140194&r2=140195&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/LoopExtractor.cpp Tue Sep 20 17:27:16 2011
@@ -105,21 +105,30 @@
     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;





More information about the llvm-commits mailing list