[PBQP] Re-commit r220642 with a workaround for quirky Visual Studio behavior.

Apparently unique_ptr'ifying NodeMetadata exposed an issue in VS where it
occasionally tries to synthesize copy constructors instead of moves. Hopefully
explicitly deleting the copy constructor and defining the move constructor will
fix this.

llvm-svn: 220649
This commit is contained in:
Lang Hames 2014-10-26 20:57:16 +00:00
parent 7de838bfe6
commit ea1026dc64

View File

@ -62,20 +62,15 @@ public:
delete[] ColCounts; delete[] ColCounts;
} }
~MatrixMetadata() {
delete[] UnsafeRows;
delete[] UnsafeCols;
}
unsigned getWorstRow() const { return WorstRow; } unsigned getWorstRow() const { return WorstRow; }
unsigned getWorstCol() const { return WorstCol; } unsigned getWorstCol() const { return WorstCol; }
const bool* getUnsafeRows() const { return UnsafeRows; } const bool* getUnsafeRows() const { return UnsafeRows.get(); }
const bool* getUnsafeCols() const { return UnsafeCols; } const bool* getUnsafeCols() const { return UnsafeCols.get(); }
private: private:
unsigned WorstRow, WorstCol; unsigned WorstRow, WorstCol;
bool* UnsafeRows; std::unique_ptr<bool[]> UnsafeRows;
bool* UnsafeCols; std::unique_ptr<bool[]> UnsafeCols;
}; };
class NodeMetadata { class NodeMetadata {
@ -88,7 +83,21 @@ public:
NotProvablyAllocatable } ReductionState; NotProvablyAllocatable } ReductionState;
NodeMetadata() : RS(Unprocessed), DeniedOpts(0), OptUnsafeEdges(nullptr){} NodeMetadata() : RS(Unprocessed), DeniedOpts(0), OptUnsafeEdges(nullptr){}
~NodeMetadata() { delete[] OptUnsafeEdges; }
NodeMetadata(NodeMetadata &&Other)
: RS(Other.RS), NumOpts(Other.NumOpts), DeniedOpts(Other.DeniedOpts),
OptUnsafeEdges(std::move(Other.OptUnsafeEdges)), VReg(Other.VReg),
OptionRegs(std::move(Other.OptionRegs)) {}
NodeMetadata& operator=(NodeMetadata &&Other) {
RS = Other.RS;
NumOpts = Other.NumOpts;
DeniedOpts = Other.DeniedOpts;
OptUnsafeEdges = std::move(Other.OptUnsafeEdges);
VReg = Other.VReg;
OptionRegs = std::move(Other.OptionRegs);
return *this;
}
void setVReg(unsigned VReg) { this->VReg = VReg; } void setVReg(unsigned VReg) { this->VReg = VReg; }
unsigned getVReg() const { return VReg; } unsigned getVReg() const { return VReg; }
@ -100,7 +109,7 @@ public:
void setup(const Vector& Costs) { void setup(const Vector& Costs) {
NumOpts = Costs.getLength() - 1; NumOpts = Costs.getLength() - 1;
OptUnsafeEdges = new unsigned[NumOpts](); OptUnsafeEdges = std::unique_ptr<unsigned[]>(new unsigned[NumOpts]());
} }
ReductionState getReductionState() const { return RS; } ReductionState getReductionState() const { return RS; }
@ -124,15 +133,18 @@ public:
bool isConservativelyAllocatable() const { bool isConservativelyAllocatable() const {
return (DeniedOpts < NumOpts) || return (DeniedOpts < NumOpts) ||
(std::find(OptUnsafeEdges, OptUnsafeEdges + NumOpts, 0) != (std::find(&OptUnsafeEdges[0], &OptUnsafeEdges[NumOpts], 0) !=
OptUnsafeEdges + NumOpts); &OptUnsafeEdges[NumOpts]);
} }
private: private:
NodeMetadata(const NodeMetadata&) LLVM_DELETED_FUNCTION;
void operator=(const NodeMetadata&) LLVM_DELETED_FUNCTION;
ReductionState RS; ReductionState RS;
unsigned NumOpts; unsigned NumOpts;
unsigned DeniedOpts; unsigned DeniedOpts;
unsigned* OptUnsafeEdges; std::unique_ptr<unsigned[]> OptUnsafeEdges;
unsigned VReg; unsigned VReg;
OptionToRegMap OptionRegs; OptionToRegMap OptionRegs;
}; };