From: Lang Hames Date: Sun, 26 Oct 2014 18:50:52 +0000 (+0000) Subject: [PBQP] Unique-ptrify some PBQP Metadata structures. No functional change. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2e3e3d94c81a60d66d3df9bab0633e061eca9026;p=platform%2Fupstream%2Fllvm.git [PBQP] Unique-ptrify some PBQP Metadata structures. No functional change. llvm-svn: 220642 --- diff --git a/llvm/include/llvm/CodeGen/RegAllocPBQP.h b/llvm/include/llvm/CodeGen/RegAllocPBQP.h index 3d242f1..2dca0e7 100644 --- a/llvm/include/llvm/CodeGen/RegAllocPBQP.h +++ b/llvm/include/llvm/CodeGen/RegAllocPBQP.h @@ -62,20 +62,15 @@ public: delete[] ColCounts; } - ~MatrixMetadata() { - delete[] UnsafeRows; - delete[] UnsafeCols; - } - unsigned getWorstRow() const { return WorstRow; } unsigned getWorstCol() const { return WorstCol; } - const bool* getUnsafeRows() const { return UnsafeRows; } - const bool* getUnsafeCols() const { return UnsafeCols; } + const bool* getUnsafeRows() const { return UnsafeRows.get(); } + const bool* getUnsafeCols() const { return UnsafeCols.get(); } private: unsigned WorstRow, WorstCol; - bool* UnsafeRows; - bool* UnsafeCols; + std::unique_ptr UnsafeRows; + std::unique_ptr UnsafeCols; }; class NodeMetadata { @@ -88,7 +83,6 @@ public: NotProvablyAllocatable } ReductionState; NodeMetadata() : RS(Unprocessed), DeniedOpts(0), OptUnsafeEdges(nullptr){} - ~NodeMetadata() { delete[] OptUnsafeEdges; } void setVReg(unsigned VReg) { this->VReg = VReg; } unsigned getVReg() const { return VReg; } @@ -100,7 +94,7 @@ public: void setup(const Vector& Costs) { NumOpts = Costs.getLength() - 1; - OptUnsafeEdges = new unsigned[NumOpts](); + OptUnsafeEdges = std::unique_ptr(new unsigned[NumOpts]()); } ReductionState getReductionState() const { return RS; } @@ -124,15 +118,15 @@ public: bool isConservativelyAllocatable() const { return (DeniedOpts < NumOpts) || - (std::find(OptUnsafeEdges, OptUnsafeEdges + NumOpts, 0) != - OptUnsafeEdges + NumOpts); + (std::find(&OptUnsafeEdges[0], &OptUnsafeEdges[NumOpts], 0) != + &OptUnsafeEdges[NumOpts]); } private: ReductionState RS; unsigned NumOpts; unsigned DeniedOpts; - unsigned* OptUnsafeEdges; + std::unique_ptr OptUnsafeEdges; unsigned VReg; OptionToRegMap OptionRegs; };