diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2010-10-13 05:54:11 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2010-10-13 05:54:11 +0000 |
commit | a8677226ab9927517705f3f9308c6c06f4e98e4e (patch) | |
tree | d76b761ec69a0c65f3ae6fa9bb280fe732c57e04 /llvm/lib/Analysis/RegionInfo.cpp | |
parent | 648594c920fb7ce76e5051f6dbd772d0566a1ee7 (diff) | |
download | bcm5719-llvm-a8677226ab9927517705f3f9308c6c06f4e98e4e.tar.gz bcm5719-llvm-a8677226ab9927517705f3f9308c6c06f4e98e4e.zip |
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.
llvm-svn: 116397
Diffstat (limited to 'llvm/lib/Analysis/RegionInfo.cpp')
-rw-r--r-- | llvm/lib/Analysis/RegionInfo.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/RegionInfo.cpp b/llvm/lib/Analysis/RegionInfo.cpp index 0bf6aad48a8..2576d4ee14a 100644 --- a/llvm/lib/Analysis/RegionInfo.cpp +++ b/llvm/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(); |