<div dir="ltr">LLVM managed to survive the 16 byte stack alignment apocalypse on 32-bit Linux without adding concepts of incoming and outgoing stack alignment, so I'm hesitant to go back and this extra complexity now.<div><div><br><div>If we're willing to tolerate the extra complexity of having yet another way to fiddle with stack alignment, then I agree separating the concepts of incoming and outgoing SP alignment is the way to go.</div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Mar 14, 2016 at 6:41 AM, Huw Davies via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I'm trying to fix an issue with clang's __force_align_arg_pointer__<br>
attribute.  The problem is described here:<br>
<a href="https://llvm.org/bugs/show_bug.cgi?id=26662" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=26662</a><br>
<br>
The problem is affecting Wine (<a href="https://www.winehq.org/" rel="noreferrer" target="_blank">https://www.winehq.org/</a>) where we have<br>
a function that is an entry-point for the x86 Win32 abi.  That<br>
function may then call functions in the host's (linux, OS/X, ...) abi.<br>
The issue is that the Win32 abi guarantees stack alignment of four<br>
bytes while the host abi is typically sixteen.<br>
<br>
This is supposed to be solved by clang's __force_align_arg_pointer__<br>
attribute.  What this does is to set the IR attribute alignstack = 16.<br>
While this does correctly realign the stack it does not change the<br>
assumption about the alignment of the incoming stack - which is still<br>
assumed to have an alignment of sixteen.  We need a way to signal to<br>
the stack layout generator that the incoming alignment can only be<br>
assumed to be four.<br>
<br>
In contrast, gcc realigns the stack but also reduces the assumed<br>
alignment of the incoming stack to four.<br>
<br>
To fix this I'm proposing a new IR attribute "incoming-stack-align"<br>
that would be set by clang in addition to the alignstack attribute.<br>
I'm attaching patches to llvm and clang that implement this.  The<br>
patches are most certainly not correct, but I'd appreciate any<br>
feedback about how to fix this.<br>
<br>
Many thanks,<br>
Huw.<br>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>