From ac31076b11371f3dc48f563698086205a2db3fc9 Mon Sep 17 00:00:00 2001 From: David Blaikie Date: Tue, 2 Sep 2014 17:42:01 +0000 Subject: [PATCH] unique_ptrify PBQPBuilder::build git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@216918 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/CodeGen/RegAllocPBQP.h | 14 ++++++++------ lib/CodeGen/RegAllocPBQP.cpp | 26 +++++++++++++------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/include/llvm/CodeGen/RegAllocPBQP.h b/include/llvm/CodeGen/RegAllocPBQP.h index 441b0f084e6..2927a78ae92 100644 --- a/include/llvm/CodeGen/RegAllocPBQP.h +++ b/include/llvm/CodeGen/RegAllocPBQP.h @@ -123,9 +123,10 @@ namespace llvm { /// Build a PBQP instance to represent the register allocation problem for /// the given MachineFunction. - virtual PBQPRAProblem *build(MachineFunction *mf, const LiveIntervals *lis, - const MachineBlockFrequencyInfo *mbfi, - const RegSet &vregs); + virtual std::unique_ptr + build(MachineFunction *mf, const LiveIntervals *lis, + const MachineBlockFrequencyInfo *mbfi, const RegSet &vregs); + private: void addSpillCosts(PBQP::Vector &costVec, PBQP::PBQPNum spillCost); @@ -142,9 +143,10 @@ namespace llvm { /// Build a PBQP instance to represent the register allocation problem for /// the given MachineFunction. - PBQPRAProblem *build(MachineFunction *mf, const LiveIntervals *lis, - const MachineBlockFrequencyInfo *mbfi, - const RegSet &vregs) override; + std::unique_ptr build(MachineFunction *mf, + const LiveIntervals *lis, + const MachineBlockFrequencyInfo *mbfi, + const RegSet &vregs) override; private: diff --git a/lib/CodeGen/RegAllocPBQP.cpp b/lib/CodeGen/RegAllocPBQP.cpp index 7475f73308f..23043a222e2 100644 --- a/lib/CodeGen/RegAllocPBQP.cpp +++ b/lib/CodeGen/RegAllocPBQP.cpp @@ -183,15 +183,15 @@ unsigned PBQPRAProblem::getPRegForOption(unsigned vreg, unsigned option) const { return allowedSet[option - 1]; } -PBQPRAProblem *PBQPBuilder::build(MachineFunction *mf, const LiveIntervals *lis, - const MachineBlockFrequencyInfo *mbfi, - const RegSet &vregs) { +std::unique_ptr +PBQPBuilder::build(MachineFunction *mf, const LiveIntervals *lis, + const MachineBlockFrequencyInfo *mbfi, const RegSet &vregs) { LiveIntervals *LIS = const_cast(lis); MachineRegisterInfo *mri = &mf->getRegInfo(); const TargetRegisterInfo *tri = mf->getSubtarget().getRegisterInfo(); - std::unique_ptr p(new PBQPRAProblem()); + auto p = llvm::make_unique(); PBQPRAGraph &g = p->getGraph(); RegSet pregs; @@ -280,7 +280,7 @@ PBQPRAProblem *PBQPBuilder::build(MachineFunction *mf, const LiveIntervals *lis, } } - return p.release(); + return p; } void PBQPBuilder::addSpillCosts(PBQP::Vector &costVec, @@ -309,12 +309,12 @@ void PBQPBuilder::addInterferenceCosts( } } -PBQPRAProblem *PBQPBuilderWithCoalescing::build(MachineFunction *mf, - const LiveIntervals *lis, - const MachineBlockFrequencyInfo *mbfi, - const RegSet &vregs) { +std::unique_ptr +PBQPBuilderWithCoalescing::build(MachineFunction *mf, const LiveIntervals *lis, + const MachineBlockFrequencyInfo *mbfi, + const RegSet &vregs) { - std::unique_ptr p(PBQPBuilder::build(mf, lis, mbfi, vregs)); + std::unique_ptr p = PBQPBuilder::build(mf, lis, mbfi, vregs); PBQPRAGraph &g = p->getGraph(); const TargetMachine &tm = mf->getTarget(); @@ -383,7 +383,7 @@ PBQPRAProblem *PBQPBuilderWithCoalescing::build(MachineFunction *mf, } } - return p.release(); + return p; } void PBQPBuilderWithCoalescing::addPhysRegCoalesce(PBQP::Vector &costVec, @@ -579,8 +579,8 @@ bool RegAllocPBQP::runOnMachineFunction(MachineFunction &MF) { while (!pbqpAllocComplete) { DEBUG(dbgs() << " PBQP Regalloc round " << round << ":\n"); - std::unique_ptr problem( - builder->build(mf, lis, mbfi, vregsToAlloc)); + std::unique_ptr problem = + builder->build(mf, lis, mbfi, vregsToAlloc); #ifndef NDEBUG if (pbqpDumpGraphs) { -- 2.11.0