summaryrefslogtreecommitdiff
path: root/lib/Analysis/RegionInfo.cpp
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2010-10-13 05:54:11 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2010-10-13 05:54:11 +0000
commitc69bd733c02a4e0ca25f7a2d6b9b05168720d373 (patch)
tree553ea2e0c3e2c8fa68eee5e065e9be169d9e7f80 /lib/Analysis/RegionInfo.cpp
parent4bcc0228dcc90385e90f22cef38b2614d3aa3cd1 (diff)
downloadllvm-c69bd733c02a4e0ca25f7a2d6b9b05168720d373.tar.gz
llvm-c69bd733c02a4e0ca25f7a2d6b9b05168720d373.tar.bz2
llvm-c69bd733c02a4e0ca25f7a2d6b9b05168720d373.tar.xz
RegioInfo: Add getExpandedRegion().
getExpandedRegion() enables us to create non canonical regions. Those regions can be used to define the largerst region, that fullfills a certain property. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116397 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/RegionInfo.cpp')
-rw-r--r--lib/Analysis/RegionInfo.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/lib/Analysis/RegionInfo.cpp b/lib/Analysis/RegionInfo.cpp
index 0bf6aad48a..2576d4ee14 100644
--- a/lib/Analysis/RegionInfo.cpp
+++ b/lib/Analysis/RegionInfo.cpp
@@ -373,6 +373,38 @@ unsigned Region::getDepth() const {
return Depth;
}
+Region *Region::getExpandedRegion() const {
+ unsigned NumSuccessors = exit->getTerminator()->getNumSuccessors();
+
+ if (NumSuccessors == 0)
+ return NULL;
+
+ for (pred_iterator PI = pred_begin(getExit()), PE = pred_end(getExit());
+ PI != PE; ++PI)
+ if (!DT->dominates(getEntry(), *PI))
+ return NULL;
+
+ Region *R = RI->getRegionFor(exit);
+
+ if (R->getEntry() != exit) {
+ if (exit->getTerminator()->getNumSuccessors() == 1)
+ return new Region(getEntry(), *succ_begin(exit), RI, DT);
+ else
+ return NULL;
+ }
+
+ while (R->getParent() && R->getParent()->getEntry() == exit)
+ R = R->getParent();
+
+ if (!DT->dominates(getEntry(), R->getExit()))
+ for (pred_iterator PI = pred_begin(getExit()), PE = pred_end(getExit());
+ PI != PE; ++PI)
+ if (!DT->dominates(R->getExit(), *PI))
+ return NULL;
+
+ return new Region(getEntry(), R->getExit(), RI, DT);
+}
+
void Region::print(raw_ostream &OS, bool print_tree, unsigned level) const {
if (print_tree)
OS.indent(level*2) << "[" << level << "] " << getNameStr();