[cfe-dev] Passing StructType arguments directly

John McCall rjmccall at apple.com
Mon Sep 19 09:37:19 PDT 2011


On Sep 19, 2011, at 12:36 AM, David Meyer wrote:
>> byval is required for correct execution of bitcode even when prototypes
>> match, and zext/sext are important for correctness under "compatible"
>> prototypes.  LLVM calls do not seem to incorporate C's undefined
>> behavior rules about calling something with the wrong prototype,
>> which is good, because the various C/C++ frontends do not always
>> agree about how to lower a C prototype into IR.
> 
> byval.. because of the hidden copy?

Yes.

>>> X86-64's ABI is daunting, but I'm not convinced it is impossible to
>>> lower this correctly given a few tweaks to the LLVM type system. (for
>>> example, by adding union and complex types).
>> 
>> See, this is exactly what I'm worried about.  I don't want to take
>> patches that add complexity to clang based on an untested hypothesis
>> that they'll be useful if you subsequently add an unknown amount of
>> complexity to LLVM.  That's particularly true when you haven't
>> actually validated that those LLVM changes will be welcome.
> 
> I intend to validate any major changes before they are made.

I'm not asking you to undergo code review, which would happen in any
case.  I'm asking you to verify that your technical direction is acceptable
downstream before muddying up clang with code that's only useful if it is.

> In either case, PNaCl will definitely be using direct struct passing,
> whether or not we can make the result match the platform ABI, so
> there's no controversy over the code written so far.

But if you don't care about matching the platform ABI, there's no reason
you can't use byval and/or indirection.

John.



More information about the cfe-dev mailing list