[PM] Make the LoopInfoBase and LoopInfo objects movable so that they can

be used as results in the new pass manager.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226559 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chandler Carruth 2015-01-20 10:58:38 +00:00
parent 934e884ae7
commit 1540633fdb

View File

@ -502,6 +502,24 @@ public:
LoopInfoBase() { }
~LoopInfoBase() { releaseMemory(); }
LoopInfoBase(LoopInfoBase &&Arg)
: BBMap(std::move(Arg.BBMap)),
TopLevelLoops(std::move(Arg.TopLevelLoops)) {
// We have to clear the arguments top level loops as we've taken ownership.
Arg.TopLevelLoops.clear();
}
LoopInfoBase &operator=(LoopInfoBase &&RHS) {
if (&RHS != this) {
BBMap = std::move(RHS.BBMap);
for (auto *L : TopLevelLoops)
delete L;
TopLevelLoops = std::move(RHS.TopLevelLoops);
RHS.TopLevelLoops.clear();
}
return *this;
}
void releaseMemory() {
BBMap.clear();
@ -635,6 +653,12 @@ class LoopInfo : public LoopInfoBase<BasicBlock, Loop> {
public:
LoopInfo() {}
LoopInfo(LoopInfo &&Arg) : BaseT(std::move(static_cast<BaseT &>(Arg))) {}
LoopInfo &operator=(LoopInfo &&RHS) {
BaseT::operator=(std::move(static_cast<BaseT &>(RHS)));
return *this;
}
// Most of the public interface is provided via LoopInfoBase.
/// updateUnloop - Update LoopInfo after removing the last backedge from a