<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </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 - CodeGen doesn't respect stack alignment skew for calls (hhvm call conv.)"
   href="https://bugs.llvm.org/show_bug.cgi?id=45275">45275</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>CodeGen doesn't respect stack alignment skew for calls (hhvm call conv.)
          </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>normal
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Common Code Generator Code
          </td>
        </tr>

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

        <tr>
          <th>Reporter</th>
          <td>engelke@in.tum.de
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When calling a function with the HHVM calling convention, the stack pointer
skewing of 8 bytes is not respected. hhvmcc (on x86-64) has a stack pointer
alignment of 16 bytes, which is skewed by 8 bytes, so that on entry the stack
pointer has a value of 0x...0 (instead of the usual 0x...8 with cdecl). This
skewing is ignored when generating code for a call to a hhvmcc function, making
it impossible to correctly call hhvmcc functions from LLVM.

Example:

    declare hhvmcc i64 @callee(i64)
    define hhvmcc i64 @caller(i64 %arg) {
      %res = notail call hhvmcc i64 @callee(i64 %arg)
      ret i64 %res
    }

Yields: 

    caller:
      call callee // <-- stack will be mis-aligned
      ret

Note that in this example "correct" code is generated when using a tail call.

PS: I'd also be willing to take a look at this myself, but I need some pointers
where to start...</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>