[cfe-dev] Passing StructType arguments directly

David Meyer pdox at google.com
Wed Sep 21 14:06:07 PDT 2011


Chris,

If we simply flatten the aggregates in the frontend, we lose type
information. This makes it harder to satisfy the platform ABI.
Keepings things as FCA is not perfect, but it does preserve more type
information. With the signature you mentioned, for example on X86-64,
whether or not "x.1" and "x.2" should be passed together in %rdi or
passed separately in %edi/%esi depends on knowing that they came from
the same structure.

We've considered using a special naming convention, which we could use
to recover the aggregate structure in the target backend. For example,
"i32 %struct.x.0, i32 %struct.x.1, i32 %struct.x.2". We could then do
the target-specific ABI lowering at the start of llc. This would
require some ingenuity to figure out how accurately represent nested
structs and unions, and some modifications to opt to avoid stripping
the special naming.

On the other hand, it would be so much nicer for us if bitcode adapted
a convention for doing this already, instead of us having to roll and
maintain our own method.

This is why I like the idea of adding an extended type system to
bitcode. To satisfy ABI requirements, extended types (like struct and
union) would only need to exist in function signatures and as function
arguments. They don't need to be completely first-class objects
throughout all of bitcode. They could be implicitly split into
individual elements at the start of a function, and explicitly created
at call sites.

- David



More information about the cfe-dev mailing list