[PBQP] NDEBUG guards added around code needed for assert.

wasConservativelyAllocatable() is only called to assert that a conservatively
allocatable node wasn't forced to spill.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229477 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jonas Paulsson 2015-02-17 07:45:06 +00:00
parent 2d460786b1
commit 7df4cae5a9
2 changed files with 16 additions and 1 deletions

View File

@ -144,6 +144,7 @@ namespace PBQP {
// TODO: Try to normalize newly added/modified edge. // TODO: Try to normalize newly added/modified edge.
} }
#ifndef NDEBUG
// Does this Cost vector have any register options ? // Does this Cost vector have any register options ?
template <typename VectorT> template <typename VectorT>
bool hasRegisterOptions(const VectorT &V) { bool hasRegisterOptions(const VectorT &V) {
@ -161,6 +162,7 @@ namespace PBQP {
return false; return false;
} }
#endif
// \brief Find a solution to a fully reduced graph by backpropagation. // \brief Find a solution to a fully reduced graph by backpropagation.
// //
@ -187,12 +189,14 @@ namespace PBQP {
RawVector v = G.getNodeCosts(NId); RawVector v = G.getNodeCosts(NId);
#ifndef NDEBUG
// Although a conservatively allocatable node can be allocated to a register, // Although a conservatively allocatable node can be allocated to a register,
// spilling it may provide a lower cost solution. Assert here that spilling // spilling it may provide a lower cost solution. Assert here that spilling
// is done by choice, not because there were no register available. // is done by choice, not because there were no register available.
if (G.getNodeMetadata(NId).wasConservativelyAllocatable()) if (G.getNodeMetadata(NId).wasConservativelyAllocatable())
assert(hasRegisterOptions(v) && "A conservatively allocatable node " assert(hasRegisterOptions(v) && "A conservatively allocatable node "
"must have available register options"); "must have available register options");
#endif
for (auto EId : G.adjEdgeIds(NId)) { for (auto EId : G.adjEdgeIds(NId)) {
const Matrix& edgeCosts = G.getEdgeCosts(EId); const Matrix& edgeCosts = G.getEdgeCosts(EId);

View File

@ -192,7 +192,11 @@ public:
NodeMetadata() NodeMetadata()
: RS(Unprocessed), NumOpts(0), DeniedOpts(0), OptUnsafeEdges(nullptr), : RS(Unprocessed), NumOpts(0), DeniedOpts(0), OptUnsafeEdges(nullptr),
VReg(0), everConservativelyAllocatable(false) {} VReg(0)
#ifndef NDEBUG
, everConservativelyAllocatable(false)
#endif
{}
// FIXME: Re-implementing default behavior to work around MSVC. Remove once // FIXME: Re-implementing default behavior to work around MSVC. Remove once
// MSVC synthesizes move constructors properly. // MSVC synthesizes move constructors properly.
@ -257,10 +261,12 @@ public:
assert(RS >= this->RS && "A node's reduction state can not be downgraded"); assert(RS >= this->RS && "A node's reduction state can not be downgraded");
this->RS = RS; this->RS = RS;
#ifndef NDEBUG
// Remember this state to assert later that a non-infinite register // Remember this state to assert later that a non-infinite register
// option was available. // option was available.
if (RS == ConservativelyAllocatable) if (RS == ConservativelyAllocatable)
everConservativelyAllocatable = true; everConservativelyAllocatable = true;
#endif
} }
@ -286,9 +292,11 @@ public:
&OptUnsafeEdges[NumOpts]); &OptUnsafeEdges[NumOpts]);
} }
#ifndef NDEBUG
bool wasConservativelyAllocatable() const { bool wasConservativelyAllocatable() const {
return everConservativelyAllocatable; return everConservativelyAllocatable;
} }
#endif
private: private:
ReductionState RS; ReductionState RS;
@ -297,7 +305,10 @@ private:
std::unique_ptr<unsigned[]> OptUnsafeEdges; std::unique_ptr<unsigned[]> OptUnsafeEdges;
unsigned VReg; unsigned VReg;
GraphMetadata::AllowedRegVecRef AllowedRegs; GraphMetadata::AllowedRegVecRef AllowedRegs;
#ifndef NDEBUG
bool everConservativelyAllocatable; bool everConservativelyAllocatable;
#endif
}; };
class RegAllocSolverImpl { class RegAllocSolverImpl {