[cfe-commits] Alignment of return from __builtin_alloca
chandlerc at google.com
Thu Jun 7 16:33:14 PDT 2012
On Thu, Jun 7, 2012 at 4:10 PM, Joerg Sonnenberger
<joerg at britannica.bec.de>wrote:
> On Thu, Jun 07, 2012 at 03:31:06PM -0700, David Sehr wrote:
> > Just out of curiosity, how do those x86 platforms handle
> > stack-allocated SSE2 variables? Do they just always use the unaligned
> > variants of the instructions?
> > This was the reason that the Linux x86 (32 and 64) ABIs now align
> > stacks 0mod16, I thought.
> The reason is more that until very recently, GCC just created broken
> code that. The only way to do it correctly is by realigning the stack.
Which both GCC and LLVM now do...
> At least we are getting to the point where LLVM handles all cases
> correctly. Requiring larger than natural stack alignment for allocar
> at the very least adds an additional AND to all functions using dynamic
> allocas. That said, unlike malloc and the posix_memalign interface,
> expecting anything but natural alignment
> for memory returned by alloca seems to be a very strong assumption...
Regardless of how it seems, there is evidence that GCC at least does this,
and it seems quite likely that a great deal of code expects equivalent
alignment guarantees for 'alloca' and 'malloc'. I think it is a mistake to
not provide such alignment. However, it does seem like this should be no
more than an 'and' instruction in the worst case (we don't have known
alignment of the stack).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-commits