From 7df4cae5a9524e8f565bc664c695e6ecc6b463fb Mon Sep 17 00:00:00 2001 From: Jonas Paulsson Date: Tue, 17 Feb 2015 07:45:06 +0000 Subject: [PATCH] [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 --- include/llvm/CodeGen/PBQP/ReductionRules.h | 4 ++++ include/llvm/CodeGen/RegAllocPBQP.h | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/llvm/CodeGen/PBQP/ReductionRules.h b/include/llvm/CodeGen/PBQP/ReductionRules.h index 8f54ec93dd2..d4a544bfe72 100644 --- a/include/llvm/CodeGen/PBQP/ReductionRules.h +++ b/include/llvm/CodeGen/PBQP/ReductionRules.h @@ -144,6 +144,7 @@ namespace PBQP { // TODO: Try to normalize newly added/modified edge. } +#ifndef NDEBUG // Does this Cost vector have any register options ? template bool hasRegisterOptions(const VectorT &V) { @@ -161,6 +162,7 @@ namespace PBQP { return false; } +#endif // \brief Find a solution to a fully reduced graph by backpropagation. // @@ -187,12 +189,14 @@ namespace PBQP { RawVector v = G.getNodeCosts(NId); +#ifndef NDEBUG // Although a conservatively allocatable node can be allocated to a register, // spilling it may provide a lower cost solution. Assert here that spilling // is done by choice, not because there were no register available. if (G.getNodeMetadata(NId).wasConservativelyAllocatable()) assert(hasRegisterOptions(v) && "A conservatively allocatable node " "must have available register options"); +#endif for (auto EId : G.adjEdgeIds(NId)) { const Matrix& edgeCosts = G.getEdgeCosts(EId); diff --git a/include/llvm/CodeGen/RegAllocPBQP.h b/include/llvm/CodeGen/RegAllocPBQP.h index a117eb070f0..827c4c90925 100644 --- a/include/llvm/CodeGen/RegAllocPBQP.h +++ b/include/llvm/CodeGen/RegAllocPBQP.h @@ -192,7 +192,11 @@ public: NodeMetadata() : 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 // MSVC synthesizes move constructors properly. @@ -257,10 +261,12 @@ public: assert(RS >= this->RS && "A node's reduction state can not be downgraded"); this->RS = RS; +#ifndef NDEBUG // Remember this state to assert later that a non-infinite register // option was available. if (RS == ConservativelyAllocatable) everConservativelyAllocatable = true; +#endif } @@ -286,9 +292,11 @@ public: &OptUnsafeEdges[NumOpts]); } +#ifndef NDEBUG bool wasConservativelyAllocatable() const { return everConservativelyAllocatable; } +#endif private: ReductionState RS; @@ -297,7 +305,10 @@ private: std::unique_ptr OptUnsafeEdges; unsigned VReg; GraphMetadata::AllowedRegVecRef AllowedRegs; + +#ifndef NDEBUG bool everConservativelyAllocatable; +#endif }; class RegAllocSolverImpl { -- 2.34.1