[patch] Align i64 to 32 bits on ppc32-darwin

Iain Sandoe iain at codesourcery.com
Wed Dec 18 01:32:18 PST 2013

Hi Rafael,

Things are slightly more complicated for long long on m32** darwin.

When in memory, long long will be aligned 'naturally' - 64b.

For embedded structure alignment the "power" rules apply - 

When an aggregate has a long-long as the first element (or, in fact, a double), then the alignment will be 64 - otherwise it will be 32
(assuming no vector or long doubles are present).

Note that, AFAIR, one needs to "look through" the first element of nested aggregates to determine whether this rule applies.

the attached code produces:

align f = 4 t = 8
ls1 align 8, size 16 offset x 0
ls2 align 4, size 12 offset x 4
ls3 align 4, size 12 offset x 4
align a = 8 b = 8 bar = 8


Once again, on the stack in variadic calls, things are different - IIRC, the alignment is only guaranteed to be 32 there (but still need to check up). 


** for m64 darwin (which is not yet fully implemented in the back end), "natural" alignment rules apply to structure embedding and the result is:

align f = 8 t = 8
ls1 align 8, size 16 offset x 0
ls2 align 8, size 16 offset x 8
ls3 align 8, size 16 offset x 8
align a = 8 b = 8 bar = 8

-------------- next part --------------
A non-text attachment was scrubbed...
Name: long-long-1.c
Type: application/octet-stream
Size: 1012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131218/b59a74f1/attachment.obj>
-------------- next part --------------

On 18 Dec 2013, at 06:32, David Fang wrote:

> 	Thanks for noticing this!  Was the only consequence of this just over-alignment?  Could this explain any possible wrong-code generation?
>> We used to to this before r134367 and it looks like that change was
>> unintentional for ppc32-darwin.

More information about the llvm-commits mailing list