[PATCH] D31719: [RegionInfo] Fix dangling references created by moving RegionInfo objects
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 05:07:35 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL301175: [RegionInfo] Fix dangling references created by moving RegionInfo objects (authored by pfaffe).
Changed prior to commit:
https://reviews.llvm.org/D31719?vs=94349&id=96383#toc
Repository:
rL LLVM
https://reviews.llvm.org/D31719
Files:
llvm/trunk/include/llvm/Analysis/RegionInfo.h
Index: llvm/trunk/include/llvm/Analysis/RegionInfo.h
===================================================================
--- llvm/trunk/include/llvm/Analysis/RegionInfo.h
+++ llvm/trunk/include/llvm/Analysis/RegionInfo.h
@@ -708,10 +708,24 @@
/// 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 @@
~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;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31719.96383.patch
Type: text/x-patch
Size: 1468 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170424/8b3ef60b/attachment.bin>
More information about the llvm-commits
mailing list