diff options
author | Tobias Grosser <grosser@fim.uni-passau.de> | 2010-10-13 05:54:09 +0000 |
---|---|---|
committer | Tobias Grosser <grosser@fim.uni-passau.de> | 2010-10-13 05:54:09 +0000 |
commit | 9649390e1fcb6d42e228364230f16409ad150fef (patch) | |
tree | 6dd3642251d084b98531ae60735def4df9d95d7a /lib/Analysis/RegionInfo.cpp | |
parent | 9ee5c5077690a4de31e22bb9e135deb6da3f68fb (diff) | |
download | llvm-9649390e1fcb6d42e228364230f16409ad150fef.tar.gz llvm-9649390e1fcb6d42e228364230f16409ad150fef.tar.bz2 llvm-9649390e1fcb6d42e228364230f16409ad150fef.tar.xz |
RegionInfo: Enhance addSubregion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@116395 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/RegionInfo.cpp')
-rw-r--r-- | lib/Analysis/RegionInfo.cpp | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/lib/Analysis/RegionInfo.cpp b/lib/Analysis/RegionInfo.cpp index 99c2eed343..75ca61f67c 100644 --- a/lib/Analysis/RegionInfo.cpp +++ b/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()); } |