summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Analysis/RegionInfo.h5
-rw-r--r--lib/Analysis/RegionInfo.cpp6
2 files changed, 8 insertions, 3 deletions
diff --git a/include/llvm/Analysis/RegionInfo.h b/include/llvm/Analysis/RegionInfo.h
index 4e7d303..b6ac1b3 100644
--- a/include/llvm/Analysis/RegionInfo.h
+++ b/include/llvm/Analysis/RegionInfo.h
@@ -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.
///
diff --git a/lib/Analysis/RegionInfo.cpp b/lib/Analysis/RegionInfo.cpp
index 9d84f55..d26135c 100644
--- a/lib/Analysis/RegionInfo.cpp
+++ b/lib/Analysis/RegionInfo.cpp
@@ -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();
}