diff options
author | Dan Gohman <gohman@apple.com> | 2009-05-08 20:07:23 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-05-08 20:07:23 +0000 |
commit | 1827e8263c9cb5dc29eea4999d8729f7376af4e1 (patch) | |
tree | 420f8a61225f5df0403d38d46452880a2756e092 | |
parent | 0269d3cbf37227c48b7ce0f9710f0c6a15ff6fa9 (diff) | |
download | external_llvm-1827e8263c9cb5dc29eea4999d8729f7376af4e1.zip external_llvm-1827e8263c9cb5dc29eea4999d8729f7376af4e1.tar.gz external_llvm-1827e8263c9cb5dc29eea4999d8729f7376af4e1.tar.bz2 |
Add a getExitBlock utility function to LoopInfo which returns the
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
-rw-r--r-- | include/llvm/Analysis/LoopInfo.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 01e5fa9..69773a6 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -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. |