[llvm] r313611 - [LLVM] [RegionInfo] Introduce getExitingBlocks to get all predecessors of Exit in the current region.

Hongbin Zheng via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 18 21:59:28 PDT 2017


Author: ether
Date: Mon Sep 18 21:59:27 2017
New Revision: 313611

URL: http://llvm.org/viewvc/llvm-project?rev=313611&view=rev
Log:
[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

Modified:
    llvm/trunk/include/llvm/Analysis/RegionInfo.h
    llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h

Modified: llvm/trunk/include/llvm/Analysis/RegionInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/RegionInfo.h?rev=313611&r1=313610&r2=313611&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/RegionInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/RegionInfo.h Mon Sep 18 21:59:27 2017
@@ -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.

Modified: llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h?rev=313611&r1=313610&r2=313611&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h Mon Sep 18 21:59:27 2017
@@ -178,6 +178,29 @@ typename RegionBase<Tr>::BlockT *RegionB
 }
 
 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;




More information about the llvm-commits mailing list