[llvm-commits] [PATCH, PowerPC, RFC] Small structs passed in registers must be right-aligned for 64-bit SVR4 ABI

William J. Schmidt wschmidt at linux.vnet.ibm.com
Mon Sep 17 12:38:40 PDT 2012


Greetings,

The attached patch fixes an ABI incompatibility for 64-bit SVR4 PowerPC.
If an aggregate fewer than 8 bytes in size is passed in a register, it
must be passed with padding on the left, not on the right.  That is, the
aggregate must be right-justified in the register.  Note that alignment
padding may still be used on the right end of the argument; thus "struct
x { int a; char b; };" has 5 bytes of data and 3 bytes of trailing
padding since the struct requires 4-byte alignment.  With #pragma
pack(1), however, the same structure passed in a register must have 5
bytes of data and 3 bytes of leading padding.

The existing code for passing structs is pretty inefficient (overusing
memcpy) and I have made no effort to improve this for now.  Eventually
the poor code generation should be addressed also, but my purpose today
is just to make the generated code correct.

The test case verifies that aggregates of size 1 through 7 are passed
correctly by the caller and retrieved correctly by the callee.  There
are two versions of the test code:  one with aggregates using natural
alignment, and one with aggregates using #pragma pack(1).

I don't yet have commit authority, so I would appreciate it if someone
could commit this after the review period.

Thanks!
Bill
-------------- next part --------------
A non-text attachment was scrubbed...
Name: structs-2012-09-17.patch
Type: text/x-patch
Size: 20638 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120917/cee38a24/attachment.bin>


More information about the llvm-commits mailing list