<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 --- - Invalid prolog/epilog on Win64"
   href="http://llvm.org/bugs/show_bug.cgi?id=16779">16779</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Invalid prolog/epilog on Win64
          </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>Windows NT
          </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>Backend: X86
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>nico.rieck@gmail.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>The "Prolog and Epilog" section
<<a href="http://msdn.microsoft.com/en-us/library/tawsa7cb.aspx">http://msdn.microsoft.com/en-us/library/tawsa7cb.aspx</a>> 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</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>