[PATCH] D36210: [LLVM] [RegionInfo] Introduce getExitingBlocks to get all predecessors of Exit in the current region.

Hongbin Zheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 1 22:55:14 PDT 2017


etherzhhb created this revision.

This function will return true if all predecessors of Exit are in the current region, false otherwise.


Repository:
  rL LLVM

https://reviews.llvm.org/D36210

Files:
  include/llvm/Analysis/RegionInfo.h
  include/llvm/Analysis/RegionInfoImpl.h


Index: include/llvm/Analysis/RegionInfoImpl.h
===================================================================
--- include/llvm/Analysis/RegionInfoImpl.h
+++ include/llvm/Analysis/RegionInfoImpl.h
@@ -179,6 +179,29 @@
 }
 
 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 *Pred;
Index: include/llvm/Analysis/RegionInfo.h
===================================================================
--- include/llvm/Analysis/RegionInfo.h
+++ include/llvm/Analysis/RegionInfo.h
@@ -399,6 +399,11 @@
   ///         else NULL.
   BlockT *getExitingBlock() const;
 
+  /// @brief Collect all block 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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36210.109275.patch
Type: text/x-patch
Size: 1481 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170802/c761deb5/attachment.bin>


More information about the llvm-commits mailing list