[cfe-commits] Alignment of return from __builtin_alloca

Chandler Carruth chandlerc at google.com
Fri Jun 8 13:57:47 PDT 2012

On Fri, Jun 8, 2012 at 12:39 PM, David Sehr <sehr at google.com> wrote:

> To back up a couple of steps:
> 1) __builtin_alloca currently returns a value aligned less than the
> stack frame (basically always 0mod4) for LLVM, which is incompatible
> with the same builtin in gcc, which seems bad.
> 2) I'm proposing aligning __builtin_alloca return values to SuitableAlign.

I don't think we need to back up further than this...

> How about we proceed with aligning __builtin_alloca

Yes. Let's just align it to SuitableAlign. As Jakob and I have pointed out,
the cost of this is minimal. You shouldn't have to do anything in clang
here -- just emit the alloca with the alignment constraint. In LLVM we
should ensure that this alignment constraint is satisfied either by
existing stack alignment constraints (if present) or by codegening a
sufficiently large alloca and masking off the low bits.

I don't think we need to have some theoretically pure model for
__builtin_alloca -- I think we just want to be able to placement new any
object which is not over-aligned into the allocated space -- exactly what
making it suitably aligned provides.

I also don't think we want to change the stack alignment of any targets --
that's an ABI break. We've already suffered enough for the ABI breaks
imposed on x86-32.

I also don't think we can change suitable alignment of any targets --
that's an even worse ABI break, and will break piles of code.

Fortunately I don't think these are blocking issues. =]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120608/d1ac3271/attachment.html>

More information about the cfe-commits mailing list