<html>
    <head>
      <base href="https://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 --- - clang: x86: __force_align_arg_pointer__ assumes that stack arguments are aligned"
   href="https://llvm.org/bugs/show_bug.cgi?id=26662">26662</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang: x86: __force_align_arg_pointer__ assumes that stack arguments are aligned
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>Macintosh
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>MacOS X
          </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>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>huw@codeweavers.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr>

        <tr>
          <th>Classification</th>
          <td>Unclassified
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When accessing stack arguments in a function marked with the
__force_align_arg_pointer__ attibute, the generated code assumes that the stack
args are 16-byte aligned.  The point of re-aligning the stack with this
attribute is that the stack may not be so aligned.

This is of importance to Wine, where the caller is win32 code with 4-byte
alignment, yet the code is running on a OS/X / Linux host with 16-byte
alignment.

When the function below is compiled with:
clang -O1 -m32  -fno-stack-protector -c  ~/test.c
(stack protection disabled just to simplify disassembly)

struct sixteen
{
    char b[16];
};

void __attribute__((__force_align_arg_pointer__)) __attribute__((__stdcall__))
test_fn( struct sixteen s )
{
    volatile struct sixteen d = s;
}


We get:
_test_fn:
00000000        pushl   %ebp
00000001        movl    %esp, %ebp
00000003        andl    $-0x10, %esp
00000006        subl    $0x20, %esp
00000009        movaps  0x8(%ebp), %xmm0
0000000d        movaps  %xmm0, (%esp)
00000011        movl    %ebp, %esp
00000013        popl    %ebp
00000014        ret     $0x10

Note that while the stack is successfully re-aligned (andl $-0x10, %esp), the
movaps 0x8(%ebp), %xmm0 assumes that the stack was originally 16-byte aligned.
It should not make that assumption.</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>