[llvm] r220642 - [PBQP] Unique-ptrify some PBQP Metadata structures. No functional change.
David Blaikie
dblaikie at gmail.com
Sun Oct 26 14:18:04 PDT 2014
On Sun, Oct 26, 2014 at 11:50 AM, Lang Hames <lhames at gmail.com> wrote:
> Author: lhames
> Date: Sun Oct 26 13:50:52 2014
> New Revision: 220642
>
> URL: http://llvm.org/viewvc/llvm-project?rev=220642&view=rev
> Log:
> [PBQP] Unique-ptrify some PBQP Metadata structures. No functional change.
>
> Modified:
> llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h
>
> Modified: llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h?rev=220642&r1=220641&r2=220642&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h Sun Oct 26 13:50:52 2014
> @@ -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<bool[]> UnsafeRows;
> + std::unique_ptr<bool[]> UnsafeCols;
>
arrays of bool are a bit sparse (8 bits per bool) - you might find a
BitVector more suitable.
> };
>
> 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<unsigned[]>(new unsigned[NumOpts]());
>
(I'd just use reset here, since there's no make_unique for arrays)
> }
>
> 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) !=
>
I don't /think/ you can index past the end of an array, so you'll have to
do it as OptUnsafeEdges.get() + NumOpts (& similarly for the beginning, if
the sequence can be zero-length).
> + &OptUnsafeEdges[NumOpts]);
> }
>
> private:
> ReductionState RS;
> unsigned NumOpts;
> unsigned DeniedOpts;
> - unsigned* OptUnsafeEdges;
> + std::unique_ptr<unsigned[]> OptUnsafeEdges;
> unsigned VReg;
> OptionToRegMap OptionRegs;
> };
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141026/4dd4f97c/attachment.html>
More information about the llvm-commits
mailing list