summaryrefslogtreecommitdiff
path: root/include/llvm/Analysis/RegionInfo.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-04-26 19:45:00 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-04-26 19:45:00 +0000
commit12f3ca4cdb95b193af905a00e722a4dcb40b3de3 (patch)
treeae1a7fcfc24a8d4b23206c57121c3f361d4b7f84 /include/llvm/Analysis/RegionInfo.h
parentd99dafe2e4a385dd2a6c76da6d8258deb100657b (diff)
Diffstat (limited to 'include/llvm/Analysis/RegionInfo.h')
-rw-r--r--include/llvm/Analysis/RegionInfo.h22
1 files changed, 19 insertions, 3 deletions
diff --git a/include/llvm/Analysis/RegionInfo.h b/include/llvm/Analysis/RegionInfo.h
index caeb21db613e7..16ee07fa31771 100644
--- a/include/llvm/Analysis/RegionInfo.h
+++ b/include/llvm/Analysis/RegionInfo.h
@@ -708,10 +708,24 @@ class RegionInfoBase {
/// The top level region.
RegionT *TopLevelRegion;
-private:
/// Map every BB to the smallest region, that contains BB.
BBtoRegionMap BBtoRegion;
+protected:
+ /// \brief Update refences to a RegionInfoT held by the RegionT managed here
+ ///
+ /// This is a post-move helper. Regions hold references to the owning
+ /// RegionInfo object. After a move these need to be fixed.
+ template<typename TheRegionT>
+ void updateRegionTree(RegionInfoT &RI, TheRegionT *R) {
+ if (!R)
+ return;
+ R->RI = &RI;
+ for (auto &SubR : *R)
+ updateRegionTree(RI, SubR.get());
+ }
+
+private:
/// \brief Wipe this region tree's state without releasing any resources.
///
/// This is essentially a post-move helper only. It leaves the object in an
@@ -879,10 +893,12 @@ public:
~RegionInfo() override;
- RegionInfo(RegionInfo &&Arg)
- : Base(std::move(static_cast<Base &>(Arg))) {}
+ RegionInfo(RegionInfo &&Arg) : Base(std::move(static_cast<Base &>(Arg))) {
+ updateRegionTree(*this, TopLevelRegion);
+ }
RegionInfo &operator=(RegionInfo &&RHS) {
Base::operator=(std::move(static_cast<Base &>(RHS)));
+ updateRegionTree(*this, TopLevelRegion);
return *this;
}