[llvm] r229400 - [PBQP] Improve the assert for conservatively allocatables.

Jonas Paulsson jonas.paulsson at ericsson.com
Mon Feb 16 07:39:26 PST 2015


Author: jonpa
Date: Mon Feb 16 09:39:26 2015
New Revision: 229400

URL: http://llvm.org/viewvc/llvm-project?rev=229400&view=rev
Log:
[PBQP] Improve the assert for conservatively allocatables.

Remember if the node ever was in this state instead of checking just the
final state.

Reviewed by Arnaud de Grandmaison.

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=229400&r1=229399&r2=229400&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/PBQP/ReductionRules.h (original)
+++ llvm/trunk/include/llvm/CodeGen/PBQP/ReductionRules.h Mon Feb 16 09:39:26 2015
@@ -190,7 +190,7 @@ namespace PBQP {
       // 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).isConservativelyAllocatable())
+      if (G.getNodeMetadata(NId).wasConservativelyAllocatable())
         assert(hasRegisterOptions(v) && "A conservatively allocatable node "
                                         "must have available register options");
 

Modified: llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h?rev=229400&r1=229399&r2=229400&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h (original)
+++ llvm/trunk/include/llvm/CodeGen/RegAllocPBQP.h Mon Feb 16 09:39:26 2015
@@ -192,7 +192,7 @@ public:
 
   NodeMetadata()
     : RS(Unprocessed), NumOpts(0), DeniedOpts(0), OptUnsafeEdges(nullptr),
-      VReg(0) {}
+      VReg(0), everConservativelyAllocatable(false) {}
 
   // FIXME: Re-implementing default behavior to work around MSVC. Remove once
   // MSVC synthesizes move constructors properly.
@@ -256,8 +256,14 @@ public:
   void setReductionState(ReductionState RS) {
     assert(RS >= this->RS && "A node's reduction state can not be downgraded");
     this->RS = RS;
+
+    // Remember this state to assert later that a non-infinite register
+    // option was available.
+    if (RS == ConservativelyAllocatable)
+      everConservativelyAllocatable = true;
   }
 
+
   void handleAddEdge(const MatrixMetadata& MD, bool Transpose) {
     DeniedOpts += Transpose ? MD.getWorstRow() : MD.getWorstCol();
     const bool* UnsafeOpts =
@@ -280,6 +286,10 @@ public:
        &OptUnsafeEdges[NumOpts]);
   }
 
+  bool wasConservativelyAllocatable() const {
+    return everConservativelyAllocatable;
+  }
+
 private:
   ReductionState RS;
   unsigned NumOpts;
@@ -287,6 +297,7 @@ private:
   std::unique_ptr<unsigned[]> OptUnsafeEdges;
   unsigned VReg;
   GraphMetadata::AllowedRegVecRef AllowedRegs;
+  bool everConservativelyAllocatable;
 };
 
 class RegAllocSolverImpl {





More information about the llvm-commits mailing list