[cxx-abi-dev] Inlining requirements for ABI functionality
John McCall
rjmccall at apple.com
Thu Dec 8 01:40:42 UTC 2011
On Dec 7, 2011, at 4:42 PM, Dennis Handly wrote:
>> because in general you cannot inline virtual methods into their call sites.
>
> Only if you have a switch to check the typeids of the most common cases?
There are places you can devirtualize calls because you know the
most-derived class — for example, if the object is a local variable or was
recently allocated using "new".
>> 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 ...
>
> With IA64 and both register and memory stacks, it is a simple matter to
> shuffle down the 8 registers and leave the memory stack in place.
Oh, yes, I see how this would work on IA64 due to the magic of the
register stack having a distinct backing store. Fine. I now know one
psABI where it is possible to do this without inlining or using a private
shared function. :)
>> Clang just gives up and inlines in this case.
>
> Is there a lot of bloat?
Variadic functions are rare, and variadic virtual functions are rarer.
I've never actually seen a variadic virtual function in the wild that had
a covariant return type that needed a thunk. I *have* seen a variadic
virtual function that needed a this-adjustment thunk, though; it was a
printf-like debugging method.
John.
More information about the cxx-abi-dev
mailing list