[cfe-dev] Passing StructType arguments directly

John McCall rjmccall at apple.com
Sun Sep 18 23:35:41 PDT 2011


On Sep 18, 2011, at 7:48 PM, David Meyer wrote:
>> LLVM IR is not a high-level representation.  "LL" is right there
>> in the name. :)  If it's critical that you maintain exact compatibility
>> with your platform ABI for arbitrary types, you are signing yourselves
>> up for preserving full C type information through a representation
>> that does not naturally do so.  Go ahead and read the rules for
>> passing a struct on x86-64 if you don't see the complexity here.
> 
> The IR is already "tainted" with ABI/C type system hints which are not
> required for correct execution of the bitcode (e.g. "byval", "sret",
> "zext/sext"). I don't see a problem with making this relation more
> formal, to include a little extra type information.

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.

> 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.

John.



More information about the cfe-dev mailing list