<html>
    <head>
      <base href="https://llvm.org/bugs/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW --- - The computation of spill weights and the actual insertion of the spill code may not match"
   href="https://llvm.org/bugs/show_bug.cgi?id=25210">25210</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>The computation of spill weights and the actual insertion of the spill code may not match
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Register Allocator
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>qcolombet@apple.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Right now, the spill weights used in the register allocator are computed by
lvm::calculateSpillWeightsAndHints and the VirtRegAuxInfo class.
On the other end, the code inserting the spill code is done by a spiller
instance, for instance the InlineSpiller for the GreedyAllocator.

The problem here is that the computation can be completed off compared to what
the spiller actually does. The weight is an over approximation of the actual
spill cost and because of that it is possible to spill variables that are
actually more expensive than other, in particular when rematerialization is
involved.

It would be better to unify those information. The spiller should be able to
give those weights instead of relying on a different implementation.

For instance, we patched the weight computation to better match the
InlinerSpiller behavior in:
r244439 | rlougher | 2015-08-10 04:59:44 -0700 (Mon, 10 Aug 2015) | 13 lines

Trace copies when checking for rematerializability in spill weight calculation

PR24139 contains an analysis of poor register allocation. One of the findings
was that when calculating the spill weight, a rematerializable interval once
split is no longer rematerializable. This is because the isRematerializable
check in CalcSpillWeights.cpp does not follow the copies introduced by live
range splitting (after splitting, the live interval register definition is a
copy which is not rematerializable).

We shouldn’t have to do that!</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>