<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 --- - [Statepoint] Remove explicit relocation of easily derived pointers"
   href="http://llvm.org/bugs/show_bug.cgi?id=21734">21734</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>[Statepoint] Remove explicit relocation of easily derived pointers
          </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>Linux
          </td>
        </tr>

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

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Scalar Optimizations
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>listmail@philipreames.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>For statepoints, we need to relocate any pointer (including derived pointers)
which are based on a garbage collector managed objects.  Currently, we do this
naively by explicitly recording every derived pointer for the GC to fix up.  We
can optimize this by only relocating the base pointer itself and re-indexing
off that base pointer to compute a derived pointer.

Given an input that looks like this:
%base = 
%ptr = gep %base + 15
statepoint ... %base, %ptr
%base' = gc.relocate(/*%base*/)
%ptr' = gc.relocate(/*%ptr*/)
%val = load %ptr'

We can convert it to:
%base = 
%ptr = gep %base + 15
statepoint ... %base, %ptr
%base' = gc.relocate(/*%base*/)
%ptr' = gep %base' + 15
%val = load %ptr'

There are a few benefits to this scheme:
- It reduces the required frame size since the derived pointer doesn't need to
be explicitly tracked.
- It avoids spill/reload costs for the derived pointer around safepoints.
- On architectures like x86 which support small offsets in their addressing,
avoiding the materialization of the derived address as a concrete register
value can be cheaper.
- If done early, it might assist the optimizer with alias queries involving
multiple accesses to the same object.  When each derived pointer is relocated
explicitly, the optimizer looses the information about how they're related.

There are a number of open questions which need resolved:
- What are the profitable cases of 'easily derived pointers'?  Small constant
offsets?  All constant offsets?  All geps?  
- Should this be done in CodeGenPrep or as an earlier IR transform?
- Does this need to be controlled by a target specific flag?</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>