<div>On Thu, Mar 1, 2012 at 4:29 PM, Evandro Menezes <span dir="ltr"><<a href="mailto:emenezes@codeaurora.org">emenezes@codeaurora.org</a>></span> wrote:</div><div>...<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Aligning the stack to 32 bytes when there are auto AVX vector variables present shouldn't necessarily break the x86-64 ABI, as long as smaller auto variables remain properly aligned.  A similar approach was taken for i386 in GCC in order to support SSE vectors.<br>

<br>
Perhaps you could elaborate where the ABI was violated when your patch is applied.<br></blockquote><div><br></div><div>Sorry, I confused myself. This was worked out about a year ago, so it's not in my cache.</div><div>
<br></div><div>You're right. In my last email I wrote "align the stack", when I should have written "align the frame when variable sized objects are in play". Take main(...) for example, with a few alloca's. If one would like to spill AVX regs with aligned moves, one must align the frame to 32 bytes to ensure that the spill slots are aligned correctly, since spill slots are based off of the frame pointer.</div>
<div><br></div><div>The x86-64 ABI lays out the stack frame as...</div><div><br></div><div>...</div><div>16(%rbp)  mem arg[0] </div><div>8(%rbp)    return address </div><div>0(%rbp)    previous %rbp</div><div>-8(%rbp)   stack</div>
<div><br></div><div>My patch breaks the ABI since the ABI requires the return address to be found at 8(%rbp) and mem arg[0] at 16(%rbp). Unfortunately, to align the frame at runtime, it's sometimes required to insert padding in between the two.</div>
<div><br></div><div>I'll ask for my company's permission to share my implementation. Until then, I'll have to bite my tongue. </div><div><br></div><div>-Cameron</div><div><br></div></div></div>