[llvm] r229302 - [PBQP] Assert conservativelly allocatable nodes are spilled by choice.

Arnaud A. de Grandmaison arnaud.degrandmaison at arm.com
Sun Feb 15 02:35:31 PST 2015


Author: aadg
Date: Sun Feb 15 04:35:31 2015
New Revision: 229302

URL: http://llvm.org/viewvc/llvm-project?rev=229302&view=rev
Log:
[PBQP] Assert conservativelly allocatable nodes are spilled by choice.

Modified:
    llvm/trunk/include/llvm/CodeGen/PBQP/ReductionRules.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=229302&r1=229301&r2=229302&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/PBQP/ReductionRules.h (original)
+++ llvm/trunk/include/llvm/CodeGen/PBQP/ReductionRules.h Sun Feb 15 04:35:31 2015
@@ -144,6 +144,23 @@ namespace PBQP {
     // TODO: Try to normalize newly added/modified edge.
   }
 
+  // Does this Cost vector have any register options ?
+  template <typename VectorT>
+  bool hasRegisterOptions(const VectorT &V) {
+    unsigned VL = V.getLength();
+
+    // An empty or spill only cost vector does not provide any register option.
+    if (VL <= 1)
+      return false;
+
+    // If there are registers in the cost vector, but all of them have infinite
+    // costs, then ... there is no available register.
+    for (unsigned i = 1; i < VL; ++i)
+      if (V[i] != std::numeric_limits<PBQP::PBQPNum>::infinity())
+        return true;
+
+    return false;
+  }
 
   // \brief Find a solution to a fully reduced graph by backpropagation.
   //
@@ -170,6 +187,13 @@ namespace PBQP {
 
       RawVector v = G.getNodeCosts(NId);
 
+      // 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())
+        assert(hasRegisterOptions(v) && "A conservatively allocatable node "
+                                        "must have available register options");
+
       for (auto EId : G.adjEdgeIds(NId)) {
         const Matrix& edgeCosts = G.getEdgeCosts(EId);
         if (NId == G.getEdgeNode1Id(EId)) {





More information about the llvm-commits mailing list