Index: llvm/trunk/include/llvm/Analysis/RegionInfo.h =================================================================== --- llvm/trunk/include/llvm/Analysis/RegionInfo.h +++ llvm/trunk/include/llvm/Analysis/RegionInfo.h @@ -407,6 +407,11 @@ /// 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 &Exitings) const; + /// @brief Is this a simple region? /// /// A region is simple if it has exactly one exit and one entry edge. Index: llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h =================================================================== --- llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h +++ llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h @@ -178,6 +178,29 @@ } template +bool RegionBase::getExitingBlocks( + SmallVectorImpl &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 typename RegionBase::BlockT *RegionBase::getExitingBlock() const { BlockT *exit = getExit(); BlockT *exitingBlock = nullptr;