[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
Wed Sep 19 07:21:44 PDT 2012


One last round with a couple of commentary changes.  Ok to commit?

On Tue, 2012-09-18 at 09:10 -0500, William J. Schmidt wrote:
> Here's a new version with some minor cleanups suggested by Roman.
> Thanks for consideration!
> 
> Bill
> 
> On Mon, 2012-09-17 at 14:38 -0500, William J. Schmidt wrote:
> > 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-18.patch
Type: text/x-patch
Size: 27612 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120919/e53b4fe9/attachment.bin>


More information about the llvm-commits mailing list