[LLVMbugs] [Bug 16779] New: Invalid prolog/epilog on Win64

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Aug 2 10:01:58 PDT 2013


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

            Bug ID: 16779
           Summary: Invalid prolog/epilog on Win64
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: unassignedbugs at nondot.org
          Reporter: nico.rieck at gmail.com
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

The "Prolog and Epilog" section
<http://msdn.microsoft.com/en-us/library/tawsa7cb.aspx> of Microsofts x64
conventions state:

  "These are the only legal forms for an epilog. It must consist of either an
   add RSP,constant or lea RSP,constant[FPReg], followed by a series of zero or
   more 8-byte register pops and a return or a jmp. [...]"

But LLVM uses mov to restore RSP. Also, if a stack variable has an alignment
greater than 16, RSP is realigned during the prolog which is incompatible with
x64 unwind information.

Example:

    // clang -std=c++11 -m64 -target x86_64-pc-win32 -o -
    int foo()
    {
        alignas(32) int x = 0;
        return x;
    }

Produces:

        .def     _Z3foov;
        .scl    2;
        .type   32;
        .endef
        .text
        .globl  _Z3foov
        .align  16, 0x90
_Z3foov:
        pushq   %rbp
        movq    %rsp, %rbp
        andq    $-32, %rsp // realignment before rsp is adjusted
        subq    $32, %rsp
        movl    $0, (%rsp)
        xorl    %eax, %eax
        movq    %rbp, %rsp // mov in epilog
        popq    %rbp
        ret

-- 
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/20130802/b53b6140/attachment.html>


More information about the llvm-bugs mailing list