Add a getExitBlock utility function to LoopInfo which returns the
authorDan Gohman <gohman@apple.com>
Fri, 8 May 2009 20:07:23 +0000 (20:07 +0000)
committerDan Gohman <gohman@apple.com>
Fri, 8 May 2009 20:07:23 +0000 (20:07 +0000)
exit block of a loop, if there is exactly one, similar to
getExitingBlock.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@71245 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/LoopInfo.h

index 01e5fa96fccb97a8f5bd2faad2c8bb35bde86b28..69773a66ec1a83a79275a7cc65527951bf704bc6 100644 (file)
@@ -213,6 +213,16 @@ public:
           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.