From 1540633fdb2cd4531150bf9323d4bef4c8154701 Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Tue, 20 Jan 2015 10:58:38 +0000 Subject: [PATCH] [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 --- include/llvm/Analysis/LoopInfo.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/include/llvm/Analysis/LoopInfo.h b/include/llvm/Analysis/LoopInfo.h index 18e572a1904..0b78983380f 100644 --- a/include/llvm/Analysis/LoopInfo.h +++ b/include/llvm/Analysis/LoopInfo.h @@ -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 { public: LoopInfo() {} + LoopInfo(LoopInfo &&Arg) : BaseT(std::move(static_cast(Arg))) {} + LoopInfo &operator=(LoopInfo &&RHS) { + BaseT::operator=(std::move(static_cast(RHS))); + return *this; + } + // Most of the public interface is provided via LoopInfoBase. /// updateUnloop - Update LoopInfo after removing the last backedge from a -- 2.34.1