<html>
    <head>
      <base href="http://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 --- - Teach greedy register allocator about "free" patchpoint uses"
   href="http://llvm.org/bugs/show_bug.cgi?id=22832">22832</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Teach greedy register allocator about "free" patchpoint uses
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </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>new bugs
          </td>
        </tr>

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

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

        <tr>
          <th>CC</th>
          <td>llvmbugs@cs.uiuc.edu
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Created <span class=""><a href="attachment.cgi?id=14002" name="attach_14002" title="bug.ll">attachment 14002</a> <a href="attachment.cgi?id=14002&action=edit" title="bug.ll">[details]</a></span>
bug.ll

There are several places where the spiller used by the register allocator
should be fixed to reason about virtual register uses that can be spilled for
free. Patchpoint operands that are in the set of "live values" (as opposed to
call arguments) should be able to be folded by the target (see
foldMemoryOperand). Generally, we consider runtime to be on the slow path, so
we don't care if these values are in registers or stack locations. If we did
care then the frontend should use call arguments instead with anyregcc
convention.

This test case exposes a specific issue in RAGreedy::tryLocalSplit.
$ llc bug.ll -debug-only=regalloc

The test case pseudo-IR is:

0: %v1 = call()
1: inlineasm "clobber-all"
2: patchpoint %v1
3: patchpoint %v1

Because this is all in one basic block, RAGreedy tries to find an optimial
local live range that can be assigned a physical register and spans as many
uses as possible. It treats all uses as 

Fixing this is probably not hard but not trivial either because just
eliminating patchpoint uses from the SpillKit's use set seems misleading and
dangerous. Ideally the heuristics would be adjusted for these free uses
instead. This is just involved enough that I won't have time to fix it myself.

My suggestion for anyone hitting this with a JIT is to try basic regalloc
instead. It should avoid this problem and give you better compile time.
(see createTargetRegisterAllocator).</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>