[PBQP] Improve the assert for conservatively allocatables.
authorJonas Paulsson <jonas.paulsson@ericsson.com>
Mon, 16 Feb 2015 15:39:26 +0000 (15:39 +0000)
committerJonas Paulsson <jonas.paulsson@ericsson.com>
Mon, 16 Feb 2015 15:39:26 +0000 (15:39 +0000)
Remember if the node ever was in this state instead of checking just the
final state.

Reviewed by Arnaud de Grandmaison.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229400 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/PBQP/ReductionRules.h
include/llvm/CodeGen/RegAllocPBQP.h

index dae7da4ac9fc152964b12b00ba346c0527638067..8f54ec93dd2152b8b699fa67b76a2056dcb00b5a 100644 (file)
@@ -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.
       // 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");
 
         assert(hasRegisterOptions(v) && "A conservatively allocatable node "
                                         "must have available register options");
 
index 6d709d2b5e0d43102eefa60e4728d34a0bcebcce..a117eb070f0757dbec9dc3ccb36a7215a6a2dfa1 100644 (file)
@@ -192,7 +192,7 @@ public:
 
   NodeMetadata()
     : RS(Unprocessed), NumOpts(0), DeniedOpts(0), OptUnsafeEdges(nullptr),
 
   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.
 
   // 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;
   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 =
   void handleAddEdge(const MatrixMetadata& MD, bool Transpose) {
     DeniedOpts += Transpose ? MD.getWorstRow() : MD.getWorstCol();
     const bool* UnsafeOpts =
@@ -280,6 +286,10 @@ public:
        &OptUnsafeEdges[NumOpts]);
   }
 
        &OptUnsafeEdges[NumOpts]);
   }
 
+  bool wasConservativelyAllocatable() const {
+    return everConservativelyAllocatable;
+  }
+
 private:
   ReductionState RS;
   unsigned NumOpts;
 private:
   ReductionState RS;
   unsigned NumOpts;
@@ -287,6 +297,7 @@ private:
   std::unique_ptr<unsigned[]> OptUnsafeEdges;
   unsigned VReg;
   GraphMetadata::AllowedRegVecRef AllowedRegs;
   std::unique_ptr<unsigned[]> OptUnsafeEdges;
   unsigned VReg;
   GraphMetadata::AllowedRegVecRef AllowedRegs;
+  bool everConservativelyAllocatable;
 };
 
 class RegAllocSolverImpl {
 };
 
 class RegAllocSolverImpl {