[llvm-commits] [llvm] r71245 - /llvm/trunk/include/llvm/Analysis/LoopInfo.h

Dan Gohman gohman at apple.com
Fri May 8 13:07:23 PDT 2009


Author: djg
Date: Fri May  8 15:07:23 2009
New Revision: 71245

URL: http://llvm.org/viewvc/llvm-project?rev=71245&view=rev
Log:
Add a getExitBlock utility function to LoopInfo which returns the
exit block of a loop, if there is exactly one, similar to
getExitingBlock.

Modified:
    llvm/trunk/include/llvm/Analysis/LoopInfo.h

Modified: llvm/trunk/include/llvm/Analysis/LoopInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopInfo.h?rev=71245&r1=71244&r2=71245&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopInfo.h Fri May  8 15:07:23 2009
@@ -213,6 +213,16 @@
           ExitBlocks.push_back(*I);
   }
 
+  /// getExitBlock - If getExitBlocks would return exactly one block,
+  /// return that block. Otherwise return null.
+  BlockT *getExitBlock() const {
+    SmallVector<BlockT*, 8> ExitBlocks;
+    getExitBlocks(ExitBlocks);
+    if (ExitBlocks.size() == 1)
+      return ExitBlocks[0];
+    return 0;
+  }
+
   /// getUniqueExitBlocks - Return all unique successor blocks of this loop. 
   /// These are the blocks _outside of the current loop_ which are branched to.
   /// This assumes that loop is in canonical form.





More information about the llvm-commits mailing list