[llvm] r285018 - [pbqp] Delete some dead code, NFC.
Vedant Kumar via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 24 13:35:35 PDT 2016
Author: vedantk
Date: Mon Oct 24 15:35:35 2016
New Revision: 285018
URL: http://llvm.org/viewvc/llvm-project?rev=285018&view=rev
Log:
[pbqp] Delete some dead code, NFC.
I took the opportunity to replace some copy|move constructors|assignment
operators with default implementations.
As a follow-up, I plan on threading unique_ptr<T []> through a few areas
per David Blaikie's advice.
Differential Revision: https://reviews.llvm.org/D24424
Modified:
llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h
llvm/trunk/include/llvm/CodeGen/PBQP/Math.h
llvm/trunk/include/llvm/CodeGen/PBQP/Solution.h
llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h
Modified: llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h?rev=285018&r1=285017&r2=285018&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h (original)
+++ llvm/trunk/include/llvm/CodeGen/PBQP/Graph.h Mon Oct 24 15:35:35 2016
@@ -110,13 +110,6 @@ namespace PBQP {
ThisEdgeAdjIdxs[1] = NodeEntry::getInvalidAdjEdgeIdx();
}
- void invalidate() {
- NIds[0] = NIds[1] = Graph::invalidNodeId();
- ThisEdgeAdjIdxs[0] = ThisEdgeAdjIdxs[1] =
- NodeEntry::getInvalidAdjEdgeIdx();
- Costs = nullptr;
- }
-
void connectToN(Graph &G, EdgeId ThisEdgeId, unsigned NIdx) {
assert(ThisEdgeAdjIdxs[NIdx] == NodeEntry::getInvalidAdjEdgeIdx() &&
"Edge already connected to NIds[NIdx].");
@@ -124,15 +117,6 @@ namespace PBQP {
ThisEdgeAdjIdxs[NIdx] = N.addAdjEdgeId(ThisEdgeId);
}
- void connectTo(Graph &G, EdgeId ThisEdgeId, NodeId NId) {
- if (NId == NIds[0])
- connectToN(G, ThisEdgeId, 0);
- else {
- assert(NId == NIds[1] && "Edge does not connect NId.");
- connectToN(G, ThisEdgeId, 1);
- }
- }
-
void connect(Graph &G, EdgeId ThisEdgeId) {
connectToN(G, ThisEdgeId, 0);
connectToN(G, ThisEdgeId, 1);
Modified: llvm/trunk/include/llvm/CodeGen/PBQP/Math.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PBQP/Math.h?rev=285018&r1=285017&r2=285018&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/PBQP/Math.h (original)
+++ llvm/trunk/include/llvm/CodeGen/PBQP/Math.h Mon Oct 24 15:35:35 2016
@@ -27,25 +27,17 @@ public:
/// \brief Construct a PBQP vector of the given size.
explicit Vector(unsigned Length)
- : Length(Length), Data(new PBQPNum[Length]) {
- // llvm::dbgs() << "Constructing PBQP::Vector "
- // << this << " (length " << Length << ")\n";
- }
+ : Length(Length), Data(new PBQPNum[Length]) {}
/// \brief Construct a PBQP vector with initializer.
Vector(unsigned Length, PBQPNum InitVal)
: Length(Length), Data(new PBQPNum[Length]) {
- // llvm::dbgs() << "Constructing PBQP::Vector "
- // << this << " (length " << Length << ", fill "
- // << InitVal << ")\n";
std::fill(Data, Data + Length, InitVal);
}
/// \brief Copy construct a PBQP vector.
Vector(const Vector &V)
: Length(V.Length), Data(new PBQPNum[Length]) {
- // llvm::dbgs() << "Copy-constructing PBQP::Vector " << this
- // << " from PBQP::Vector " << &V << "\n";
std::copy(V.Data, V.Data + Length, Data);
}
@@ -57,31 +49,7 @@ public:
}
/// \brief Destroy this vector, return its memory.
- ~Vector() {
- // llvm::dbgs() << "Deleting PBQP::Vector " << this << "\n";
- delete[] Data;
- }
-
- /// \brief Copy-assignment operator.
- Vector& operator=(const Vector &V) {
- // llvm::dbgs() << "Assigning to PBQP::Vector " << this
- // << " from PBQP::Vector " << &V << "\n";
- delete[] Data;
- Length = V.Length;
- Data = new PBQPNum[Length];
- std::copy(V.Data, V.Data + Length, Data);
- return *this;
- }
-
- /// \brief Move-assignment operator.
- Vector& operator=(Vector &&V) {
- delete[] Data;
- Length = V.Length;
- Data = V.Data;
- V.Length = 0;
- V.Data = nullptr;
- return *this;
- }
+ ~Vector() { delete[] Data; }
/// \brief Comparison operator.
bool operator==(const Vector &V) const {
@@ -119,14 +87,6 @@ public:
return *this;
}
- /// \brief Subtract another vector from this one.
- Vector& operator-=(const Vector &V) {
- assert(Length != 0 && Data != nullptr && "Invalid vector");
- assert(Length == V.Length && "Vector length mismatch.");
- std::transform(Data, Data + Length, V.Data, Data, std::minus<PBQPNum>());
- return *this;
- }
-
/// \brief Returns the index of the minimum value in this vector
unsigned minIndex() const {
assert(Length != 0 && Data != nullptr && "Invalid vector");
@@ -193,26 +153,6 @@ public:
/// \brief Destroy this matrix, return its memory.
~Matrix() { delete[] Data; }
- /// \brief Copy-assignment operator.
- Matrix& operator=(const Matrix &M) {
- delete[] Data;
- Rows = M.Rows; Cols = M.Cols;
- Data = new PBQPNum[Rows * Cols];
- std::copy(M.Data, M.Data + (Rows * Cols), Data);
- return *this;
- }
-
- /// \brief Move-assignment operator.
- Matrix& operator=(Matrix &&M) {
- delete[] Data;
- Rows = M.Rows;
- Cols = M.Cols;
- Data = M.Data;
- M.Rows = M.Cols = 0;
- M.Data = nullptr;
- return *this;
- }
-
/// \brief Comparison operator.
bool operator==(const Matrix &M) const {
assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
@@ -265,30 +205,6 @@ public:
return V;
}
- /// \brief Reset the matrix to the given value.
- Matrix& reset(PBQPNum Val = 0) {
- assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
- std::fill(Data, Data + (Rows * Cols), Val);
- return *this;
- }
-
- /// \brief Set a single row of this matrix to the given value.
- Matrix& setRow(unsigned R, PBQPNum Val) {
- assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
- assert(R < Rows && "Row out of bounds.");
- std::fill(Data + (R * Cols), Data + ((R + 1) * Cols), Val);
- return *this;
- }
-
- /// \brief Set a single column of this matrix to the given value.
- Matrix& setCol(unsigned C, PBQPNum Val) {
- assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
- assert(C < Cols && "Column out of bounds.");
- for (unsigned R = 0; R < Rows; ++R)
- (*this)[R][C] = Val;
- return *this;
- }
-
/// \brief Matrix transpose.
Matrix transpose() const {
assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
@@ -299,18 +215,6 @@ public:
return M;
}
- /// \brief Returns the diagonal of the matrix as a vector.
- ///
- /// Matrix must be square.
- Vector diagonalize() const {
- assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
- assert(Rows == Cols && "Attempt to diagonalize non-square matrix.");
- Vector V(Rows);
- for (unsigned r = 0; r < Rows; ++r)
- V[r] = (*this)[r][r];
- return V;
- }
-
/// \brief Add the given matrix to this one.
Matrix& operator+=(const Matrix &M) {
assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
@@ -328,49 +232,6 @@ public:
return Tmp;
}
- /// \brief Returns the minimum of the given row
- PBQPNum getRowMin(unsigned R) const {
- assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
- assert(R < Rows && "Row out of bounds");
- return *std::min_element(Data + (R * Cols), Data + ((R + 1) * Cols));
- }
-
- /// \brief Returns the minimum of the given column
- PBQPNum getColMin(unsigned C) const {
- assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
- PBQPNum MinElem = (*this)[0][C];
- for (unsigned R = 1; R < Rows; ++R)
- if ((*this)[R][C] < MinElem)
- MinElem = (*this)[R][C];
- return MinElem;
- }
-
- /// \brief Subtracts the given scalar from the elements of the given row.
- Matrix& subFromRow(unsigned R, PBQPNum Val) {
- assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
- assert(R < Rows && "Row out of bounds");
- std::transform(Data + (R * Cols), Data + ((R + 1) * Cols),
- Data + (R * Cols),
- std::bind2nd(std::minus<PBQPNum>(), Val));
- return *this;
- }
-
- /// \brief Subtracts the given scalar from the elements of the given column.
- Matrix& subFromCol(unsigned C, PBQPNum Val) {
- assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
- for (unsigned R = 0; R < Rows; ++R)
- (*this)[R][C] -= Val;
- return *this;
- }
-
- /// \brief Returns true if this is a zero matrix.
- bool isZero() const {
- assert(Rows != 0 && Cols != 0 && Data != nullptr && "Invalid matrix");
- return find_if(Data, Data + (Rows * Cols),
- std::bind2nd(std::not_equal_to<PBQPNum>(), 0)) ==
- Data + (Rows * Cols);
- }
-
private:
unsigned Rows, Cols;
PBQPNum *Data;
Modified: llvm/trunk/include/llvm/CodeGen/PBQP/Solution.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PBQP/Solution.h?rev=285018&r1=285017&r2=285018&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/PBQP/Solution.h (original)
+++ llvm/trunk/include/llvm/CodeGen/PBQP/Solution.h Mon Oct 24 15:35:35 2016
@@ -38,38 +38,6 @@ namespace PBQP {
Solution()
: r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {}
- /// \brief Number of nodes for which selections have been made.
- /// @return Number of nodes for which selections have been made.
- unsigned numNodes() const { return selections.size(); }
-
- /// \brief Records a reduction via the R0 rule. Should be called from the
- /// solver only.
- void recordR0() { ++r0Reductions; }
-
- /// \brief Returns the number of R0 reductions applied to solve the problem.
- unsigned numR0Reductions() const { return r0Reductions; }
-
- /// \brief Records a reduction via the R1 rule. Should be called from the
- /// solver only.
- void recordR1() { ++r1Reductions; }
-
- /// \brief Returns the number of R1 reductions applied to solve the problem.
- unsigned numR1Reductions() const { return r1Reductions; }
-
- /// \brief Records a reduction via the R2 rule. Should be called from the
- /// solver only.
- void recordR2() { ++r2Reductions; }
-
- /// \brief Returns the number of R2 reductions applied to solve the problem.
- unsigned numR2Reductions() const { return r2Reductions; }
-
- /// \brief Records a reduction via the RN rule. Should be called from the
- /// solver only.
- void recordRN() { ++ rNReductions; }
-
- /// \brief Returns the number of RN reductions applied to solve the problem.
- unsigned numRNReductions() const { return rNReductions; }
-
/// \brief Set the selection for a given node.
/// @param nodeId Node id.
/// @param selection Selection for nodeId.
Modified: llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h?rev=285018&r1=285017&r2=285018&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h (original)
+++ llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h Mon Oct 24 15:35:35 2016
@@ -89,26 +89,7 @@ public:
std::copy(OptVec.begin(), OptVec.end(), Opts.get());
}
- AllowedRegVector(const AllowedRegVector &Other)
- : NumOpts(Other.NumOpts), Opts(new unsigned[NumOpts]) {
- std::copy(Other.Opts.get(), Other.Opts.get() + NumOpts, Opts.get());
- }
-
- AllowedRegVector(AllowedRegVector &&Other)
- : NumOpts(std::move(Other.NumOpts)), Opts(std::move(Other.Opts)) {}
-
- AllowedRegVector& operator=(const AllowedRegVector &Other) {
- NumOpts = Other.NumOpts;
- Opts.reset(new unsigned[NumOpts]);
- std::copy(Other.Opts.get(), Other.Opts.get() + NumOpts, Opts.get());
- return *this;
- }
-
- AllowedRegVector& operator=(AllowedRegVector &&Other) {
- NumOpts = std::move(Other.NumOpts);
- Opts = std::move(Other.Opts);
- return *this;
- }
+ AllowedRegVector(AllowedRegVector &&) = default;
unsigned size() const { return NumOpts; }
unsigned operator[](size_t I) const { return Opts[I]; }
@@ -163,10 +144,6 @@ public:
return VRegItr->second;
}
- void eraseNodeIdForVReg(unsigned VReg) {
- VRegToNodeId.erase(VReg);
- }
-
AllowedRegVecRef getAllowedRegs(AllowedRegVector Allowed) {
return AllowedRegVecs.getValue(std::move(Allowed));
}
@@ -199,8 +176,6 @@ public:
#endif
{}
- // FIXME: Re-implementing default behavior to work around MSVC. Remove once
- // MSVC synthesizes move constructors properly.
NodeMetadata(const NodeMetadata &Other)
: RS(Other.RS), NumOpts(Other.NumOpts), DeniedOpts(Other.DeniedOpts),
OptUnsafeEdges(new unsigned[NumOpts]), VReg(Other.VReg),
@@ -215,48 +190,9 @@ public:
}
}
- // FIXME: Re-implementing default behavior to work around MSVC. Remove once
- // MSVC synthesizes move constructors properly.
- NodeMetadata(NodeMetadata &&Other)
- : RS(Other.RS), NumOpts(Other.NumOpts), DeniedOpts(Other.DeniedOpts),
- OptUnsafeEdges(std::move(Other.OptUnsafeEdges)), VReg(Other.VReg),
- AllowedRegs(std::move(Other.AllowedRegs))
-#ifndef NDEBUG
- , everConservativelyAllocatable(Other.everConservativelyAllocatable)
-#endif
- {}
-
- // FIXME: Re-implementing default behavior to work around MSVC. Remove once
- // MSVC synthesizes move constructors properly.
- NodeMetadata& operator=(const NodeMetadata &Other) {
- RS = Other.RS;
- NumOpts = Other.NumOpts;
- DeniedOpts = Other.DeniedOpts;
- OptUnsafeEdges.reset(new unsigned[NumOpts]);
- std::copy(Other.OptUnsafeEdges.get(), Other.OptUnsafeEdges.get() + NumOpts,
- OptUnsafeEdges.get());
- VReg = Other.VReg;
- AllowedRegs = Other.AllowedRegs;
-#ifndef NDEBUG
- everConservativelyAllocatable = Other.everConservativelyAllocatable;
-#endif
- return *this;
- }
+ NodeMetadata(NodeMetadata &&Other) = default;
- // FIXME: Re-implementing default behavior to work around MSVC. Remove once
- // MSVC synthesizes move constructors properly.
- NodeMetadata& operator=(NodeMetadata &&Other) {
- RS = Other.RS;
- NumOpts = Other.NumOpts;
- DeniedOpts = Other.DeniedOpts;
- OptUnsafeEdges = std::move(Other.OptUnsafeEdges);
- VReg = Other.VReg;
- AllowedRegs = std::move(Other.AllowedRegs);
-#ifndef NDEBUG
- everConservativelyAllocatable = Other.everConservativelyAllocatable;
-#endif
- return *this;
- }
+ NodeMetadata& operator=(NodeMetadata &&Other) = default;
void setVReg(unsigned VReg) { this->VReg = VReg; }
unsigned getVReg() const { return VReg; }
@@ -284,7 +220,6 @@ public:
#endif
}
-
void handleAddEdge(const MatrixMetadata& MD, bool Transpose) {
DeniedOpts += Transpose ? MD.getWorstRow() : MD.getWorstCol();
const bool* UnsafeOpts =
@@ -369,11 +304,6 @@ public:
handleReconnectEdge(EId, G.getEdgeNode2Id(EId));
}
- void handleRemoveEdge(EdgeId EId) {
- handleDisconnectEdge(EId, G.getEdgeNode1Id(EId));
- handleDisconnectEdge(EId, G.getEdgeNode2Id(EId));
- }
-
void handleDisconnectEdge(EdgeId EId, NodeId NId) {
NodeMetadata& NMd = G.getNodeMetadata(NId);
const MatrixMetadata& MMd = G.getEdgeCosts(EId).getMetadata();
More information about the llvm-commits
mailing list