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

Lang Hames lhames at gmail.com
Tue Feb 17 08:30:54 PST 2015


Thanks Jonas!

- Lang.

On Mon, Feb 16, 2015 at 11:45 PM, Jonas Paulsson <
jonas.paulsson at ericsson.com> wrote:

> Author: jonpa
> Date: Tue Feb 17 01:45:06 2015
> New Revision: 229477
>
> URL: http://llvm.org/viewvc/llvm-project?rev=229477&view=rev
> Log:
> [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.
>
> Modified:
>     llvm/trunk/include/llvm/CodeGen/PBQP/ReductionRules.h
>     llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h
>
> Modified: llvm/trunk/include/llvm/CodeGen/PBQP/ReductionRules.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/PBQP/ReductionRules.h?rev=229477&r1=229476&r2=229477&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/PBQP/ReductionRules.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/PBQP/ReductionRules.h Tue Feb 17
> 01:45:06 2015
> @@ -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 <typename VectorT>
>    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);
>
> Modified: llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h?rev=229477&r1=229476&r2=229477&view=diff
>
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h Tue Feb 17 01:45:06 2015
> @@ -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<unsigned[]> OptUnsafeEdges;
>    unsigned VReg;
>    GraphMetadata::AllowedRegVecRef AllowedRegs;
> +
> +#ifndef NDEBUG
>    bool everConservativelyAllocatable;
> +#endif
>  };
>
>  class RegAllocSolverImpl {
>
>
> _______________________________________________
> 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/20150217/9fac5d5b/attachment.html>


More information about the llvm-commits mailing list