[LLVMbugs] [Bug 16102] New: Clobbered Callee-Save Registers Not Saved

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue May 21 21:40:42 PDT 2013


http://llvm.org/bugs/show_bug.cgi?id=16102

            Bug ID: 16102
           Summary: Clobbered Callee-Save Registers Not Saved
           Product: new-bugs
           Version: 3.2
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: bugzilla at uhsure.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

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.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20130522/10e0e09e/attachment.html>


More information about the llvm-bugs mailing list