Use musttail for variadic method thunks when possible
authorReid Kleckner <rnk@google.com>
Fri, 6 Sep 2019 22:55:26 +0000 (22:55 +0000)
committerReid Kleckner <rnk@google.com>
Fri, 6 Sep 2019 22:55:26 +0000 (22:55 +0000)
commit28328c3771e4241366ecb7aba8963dc92b3065d7
treee2c953cb16c6e7461e3070b4d4d24e5e5f6c8aa2
parentc1779194097f0553c292750195673ae65fdc4d32
Use musttail for variadic method thunks when possible

This avoids cloning variadic virtual methods when the target supports
musttail and the return type is not covariant. I think we never
implemented this previously because it doesn't handle the covariant
case. But, in the MS ABI, there are some cases where vtable thunks must
be emitted even when the variadic method defintion is not available, so
it looks like we need to implement this. Do it for both ABIs, since it's
a nice size improvement and simplification for Itanium.

Emit an error when emitting thunks for variadic methods with a covariant
return type. This case is essentially not implementable unless the ABI
provides a way to perfectly forward variadic arguments without a tail
call.

Fixes PR43173.

Differential Revision: https://reviews.llvm.org/D67028

llvm-svn: 371269
clang/lib/CodeGen/CGVTables.cpp
clang/test/CodeGenCXX/linetable-virtual-variadic.cpp
clang/test/CodeGenCXX/ms-thunks-variadic-return.cpp [new file with mode: 0644]
clang/test/CodeGenCXX/thunks.cpp