diff options
| author | Hongbin Zheng <etherzhhb@gmail.com> | 2017-09-19 04:59:27 +0000 |
|---|---|---|
| committer | Hongbin Zheng <etherzhhb@gmail.com> | 2017-09-19 04:59:27 +0000 |
| commit | e1d3e2e66e1a8bb9c68edf56ddaca43d3440434a (patch) | |
| tree | 2a4a04f00aff7859e730364ab26de139d321b1ea | |
| parent | a80949feb5d8081d6a7bde475cb143aca5a5da21 (diff) | |
| download | bcm5719-llvm-e1d3e2e66e1a8bb9c68edf56ddaca43d3440434a.tar.gz bcm5719-llvm-e1d3e2e66e1a8bb9c68edf56ddaca43d3440434a.zip | |
[LLVM] [RegionInfo] Introduce getExitingBlocks to get all predecessors of Exit in the current region.
This function will return true if all predecessors of Exit are in the current region, false otherwise.
Differential Revision: https://reviews.llvm.org/D36210
llvm-svn: 313611
| -rw-r--r-- | llvm/include/llvm/Analysis/RegionInfo.h | 5 | ||||
| -rw-r--r-- | llvm/include/llvm/Analysis/RegionInfoImpl.h | 23 |
2 files changed, 28 insertions, 0 deletions
diff --git a/llvm/include/llvm/Analysis/RegionInfo.h b/llvm/include/llvm/Analysis/RegionInfo.h index 8e633cc3c86..71962235994 100644 --- a/llvm/include/llvm/Analysis/RegionInfo.h +++ b/llvm/include/llvm/Analysis/RegionInfo.h @@ -407,6 +407,11 @@ public: /// else NULL. BlockT *getExitingBlock() const; + /// @brief Collect all blocks of this region's single exit edge, if existing. + /// + /// @return True if this region contains all the predecessors of the exit. + bool getExitingBlocks(SmallVectorImpl<BlockT *> &Exitings) const; + /// @brief Is this a simple region? /// /// A region is simple if it has exactly one exit and one entry edge. diff --git a/llvm/include/llvm/Analysis/RegionInfoImpl.h b/llvm/include/llvm/Analysis/RegionInfoImpl.h index cd4ec0a03a9..6e522354dd9 100644 --- a/llvm/include/llvm/Analysis/RegionInfoImpl.h +++ b/llvm/include/llvm/Analysis/RegionInfoImpl.h @@ -178,6 +178,29 @@ typename RegionBase<Tr>::BlockT *RegionBase<Tr>::getEnteringBlock() const { } template <class Tr> +bool RegionBase<Tr>::getExitingBlocks( + SmallVectorImpl<BlockT *> &Exitings) const { + bool CoverAll = true; + + if (!exit) + return CoverAll; + + for (PredIterTy PI = InvBlockTraits::child_begin(exit), + PE = InvBlockTraits::child_end(exit); + PI != PE; ++PI) { + BlockT *Pred = *PI; + if (contains(Pred)) { + Exitings.push_back(Pred); + continue; + } + + CoverAll = false; + } + + return CoverAll; +} + +template <class Tr> typename RegionBase<Tr>::BlockT *RegionBase<Tr>::getExitingBlock() const { BlockT *exit = getExit(); BlockT *exitingBlock = nullptr; |

