Add Region::isTopLevelRegion().
authorTobias Grosser <grosser@fim.uni-passau.de>
Wed, 13 Oct 2010 11:02:44 +0000 (11:02 +0000)
committerTobias Grosser <grosser@fim.uni-passau.de>
Wed, 13 Oct 2010 11:02:44 +0000 (11:02 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116402 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/RegionInfo.h
lib/Analysis/RegionInfo.cpp

index 4e7d303863b880775ead46353a3b1d13d491ad9c..b6ac1b368f5ca3d50ca736acf75e087a4da07bd9 100644 (file)
@@ -292,6 +292,11 @@ public:
   /// @return The depth of the region.
   unsigned getDepth() const;
 
+  /// @brief Check if a Region is the TopLevel region.
+  ///
+  /// The toplevel region represents the whole function.
+  bool isTopLevelRegion() const { return exit == NULL; };
+
   /// @brief Return a new (non canonical) region, that is obtained by joining
   ///        this region with its predecessors.
   ///
index 9d84f55eeb5c06e70bd5a92d343ee3dfb60f6cb3..d26135c6092818e3a41c9dd4dd7894a750e9b158 100644 (file)
@@ -140,8 +140,7 @@ bool Region::isSimple() const {
 
   BasicBlock *entry = getEntry(), *exit = getExit();
 
-  // TopLevelRegion
-  if (!exit)
+  if (isTopLevelRegion())
     return false;
 
   for (pred_iterator PI = pred_begin(entry), PE = pred_end(entry); PI != PE;
@@ -810,9 +809,10 @@ RegionInfo::getCommonRegion(SmallVectorImpl<BasicBlock*> &BBs) const {
 void RegionInfo::splitBlock(BasicBlock* NewBB, BasicBlock *OldBB)
 {
   Region *R = getRegionFor(OldBB);
+
   setRegionFor(NewBB, R);
 
-  while (R->getEntry() == OldBB && R->getParent()) {
+  while (R->getEntry() == OldBB && !R->isTopLevelRegion()) {
     R->replaceEntry(NewBB);
     R = R->getParent();
   }