Original commit:
Lambda functions with inalloca parameters (which are used in 32-bit Windows) currently aren't supported because the call operator delegates to another function and forwards its arguments, and inalloca parameters can't be forwarded. (The same issue exists for variadic arguments.)
This patch emits the lambda call operator again with a different calling convention without inallocas. Then the original call operator and static invoker delegate to this new function. We also modify arrangeLLVMFunctionInfo to be able to generate a different CGFunctionInfo for delegate calls that doesn't use inalloca.
Fixes https://github.com/llvm/llvm-project/issues/28673.
Changes:
- Make sure we only emit the new callop function body if the static invoker is actually used
- Hopefully avoid making a copy of the forward types when calling the impl function.
This reverts commit 8ed7aa59f489715d39d32e72a787b8e75cfda151.
Please add a comment about this. We need to avoid copying uncopyable objects passed in misaligned inalloca argument packs.
Another approach we could take here is to check CXXRecordDecl::isTriviallyCopyable, and avoid doing the copy for such argument types. That would be non-conforming anyway, and results in an assert in CallArg::copyInto. For trivially copyable types, doing the copy may actually be good, since it's more conforming.