summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/RegionInfo.cpp
diff options
context:
space:
mode:
authorTobias Grosser <grosser@fim.uni-passau.de>2010-10-13 05:54:09 +0000
committerTobias Grosser <grosser@fim.uni-passau.de>2010-10-13 05:54:09 +0000
commitbf984fd78ebc08550d5a0a39fce5454d68e2025f (patch)
tree34f2e6b8d476be28a0458c3a60114aaf144277d7 /llvm/lib/Analysis/RegionInfo.cpp
parent8352ce5f8d7a207fd4ee3130098d450efa21c5f1 (diff)
downloadbcm5719-llvm-bf984fd78ebc08550d5a0a39fce5454d68e2025f.tar.gz
bcm5719-llvm-bf984fd78ebc08550d5a0a39fce5454d68e2025f.zip
RegionInfo: Enhance addSubregion.
llvm-svn: 116395
Diffstat (limited to 'llvm/lib/Analysis/RegionInfo.cpp')
-rw-r--r--llvm/lib/Analysis/RegionInfo.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/llvm/lib/Analysis/RegionInfo.cpp b/llvm/lib/Analysis/RegionInfo.cpp
index 99c2eed343d..75ca61f67c7 100644
--- a/llvm/lib/Analysis/RegionInfo.cpp
+++ b/llvm/lib/Analysis/RegionInfo.cpp
@@ -311,13 +311,38 @@ void Region::transferChildrenTo(Region *To) {
children.clear();
}
-void Region::addSubRegion(Region *SubRegion) {
+void Region::addSubRegion(Region *SubRegion, bool moveChildren) {
assert(SubRegion->parent == 0 && "SubRegion already has a parent!");
+ assert(std::find(begin(), end(), SubRegion) == children.end()
+ && "Subregion already exists!");
+
SubRegion->parent = this;
- // Set up the region node.
- assert(std::find(children.begin(), children.end(), SubRegion) == children.end()
- && "Node already exist!");
children.push_back(SubRegion);
+
+ if (!moveChildren)
+ return;
+
+ assert(SubRegion->children.size() == 0
+ && "SubRegions that contain children are not supported");
+
+ for (element_iterator I = element_begin(), E = element_end(); I != E; ++I)
+ if (!(*I)->isSubRegion()) {
+ BasicBlock *BB = (*I)->getNodeAs<BasicBlock>();
+
+ if (SubRegion->contains(BB))
+ RI->setRegionFor(BB, SubRegion);
+ }
+
+ std::vector<Region*> Keep;
+ for (iterator I = begin(), E = end(); I != E; ++I)
+ if (SubRegion->contains(*I) && *I != SubRegion) {
+ SubRegion->children.push_back(*I);
+ (*I)->parent = SubRegion;
+ } else
+ Keep.push_back(*I);
+
+ children.clear();
+ children.insert(children.begin(), Keep.begin(), Keep.end());
}
OpenPOWER on IntegriCloud