[cxx-abi-dev] Inlining requirements for ABI functionality

John McCall rjmccall at apple.com
Tue Dec 6 19:30:18 UTC 2011


On Dec 5, 2011, at 10:43 AM, Matthew Markland wrote:
> I am looking at some issues the compiler I support has with covariant
> return thunks and a discussion has broken out regarding whether
> various thunks need to be inlined for the compiler to be ABI
> compliant.  My take on this is that it is up to the compiler whether
> to inline the thunks if they are implemented as complete functions;
> other thunks/thunking that consists of inline code would be inlined of
> course.  A cursory search of the ABI document for "inline" didn't seem
> to call out any requirements.  My question is whether there are such
> requirements.

It's not clear to me whether you're talking about the compiler transformation
called "inlining" or the vague-linkage effect of C++'s "inline" keyword.
Usually people mean the former when they say "inlining", but your question
doesn't really make sense with that interpretation, because in general you
cannot inline virtual methods into their call sites.

If you're talking about linkage, thunks should always get exactly the same
linkage as the method implementation they're being emitted for.

If you're talking about the compiler transformation, the ABI never strictly
requires code duplication.  Thunks are designed so that you can (mostly)
implement them as calls to the primary implementation.  The exception is
for variadic methods;  if you have a thunk with a non-trivial covariant-return
adjustment for a variadic method, there is no way to simply forward the
variadic arguments, so you must either duplicate the implementation or
make all the entrypoints (even the standard one) defer to an implementation
that takes extra information detailing how to transform the result.

John.



More information about the cxx-abi-dev mailing list