[cfe-commits] [PATCH][CodeGen] Add padding to expanded struct function arguments if the ABI requires it.
John McCall
rjmccall at apple.com
Fri Nov 12 22:12:44 PST 2010
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.
More information about the cfe-commits
mailing list