[cfe-commits] [PATCH][CodeGen] Add padding to expanded struct function arguments if the ABI requires it.

Michael Spencer bigcheesegs at gmail.com
Sat Nov 13 09:43:47 PST 2010


On Sat, Nov 13, 2010 at 1:12 AM, John McCall <rjmccall at apple.com> wrote:
>
> On Nov 12, 2010, at 7:52 PM, Michael Spencer wrote:
>
>> On Fri, Nov 12, 2010 at 10:14 PM, John McCall <rjmccall at apple.com> wrote:
>>> On Oct 18, 2010, at 11:54 PM, Michael Spencer wrote:
>>>> The Microsoft ABI requires that structs passed by value as "expanded"
>>>> arguments maintain padding. This patch implements this and fixes
>>>> <http://llvm.org/bugs/show_bug.cgi?id=8398>.
>>>
>>> Sorry this has taken so long.  Can you explain how this approach is different from just not passing the struct as expanded at all, i.e. passing it byval?
>>>
>>> John.
>>
>> I thought byval was a pointer thing, would it work in this case?
>
> As I understand it, byval arguments are passed in memory by copying the pointed-to object into the appropriate position in the arguments, which is pretty much exactly what you want.  I think the pointer-is-secretly-a-struct thing is just a throwback to before we had first-class aggregates.
>
> I'm also pretty sure that expansion won't work because it screws up register-passing CCs, of which there are several we need to support on MS platforms.  For example:
>
>  struct A { int x; double d; };
>  void __fastcall foo(struct A, void *, void *);  // the pointers should be passed in registers, not the int and the padding pseudo-argument.
>
> John.

OK, so the actual problem is in X86_32ABIInfo::classifyArgumentType.
It should not be expanding small structs with padding, or any struct
at all when using fastcc.

- Michael Spencer




More information about the cfe-commits mailing list