<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 --- - Clobbered Callee-Save Registers Not Saved"
   href="http://llvm.org/bugs/show_bug.cgi?id=16102">16102</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Clobbered Callee-Save Registers Not Saved
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>3.2
          </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>bugzilla@uhsure.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>I had guessed that mark a callee-saved register as clobbered would cause LLVM
to save the register in the prologue, but it turns out not to. Specifically, I
would expect that on the x86-64, this function:

define i32 @testfun(i32 %arg)
{
 tail call void asm sideeffect  "" , "~{%r12},~{%r13}"()
 ret i32 %arg
}

Would cause both r12 and r13 to be pushed in the prologue and popped before
returning, but it actually just compiles into this:

_testfun:                               ## @testfun
Ltmp69:
## BB#0:
    ## InlineAsm Start
    ## InlineAsm End
    movl>---%edi, %eax
    ret
Ltmp70:

Just in case it was being very clever, I changed the assembly to actually
clobber r12 and r13 with no effect.

Unless I'm misunderstanding clobbering -- always a possibility -- the above
leads to unsafe code generation, as the calling function of "tempfun" will
assume r12 and r13 are safe across the call, but this function destroys them.
If I hadn't marked them as clobbered I wouldn't have been surprised at the
behavior, but the fact that I did mark them as clobbered makes this seem like a
bug.</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>