[clang] [C] Disable use of NRVO (PR #101038)

John McCall via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 29 12:08:45 PDT 2024


rjmccall wrote:

My argument above is that the x86-64 psABI requires us to not pass `&t` as the indirect return address.  Following that rule fixes the problem here even if we keep doing NRVO.

I think the approximate shape of the correct fix here is to:
(1) Use the function Eli pointed out to check whether the initializer refers to the variable being initialized.
(2) Propagate that information down in CodeGen when we're emitting into an address.
(3) When emitting a call into an address, if the return value is trivially copyable and the initialized address is potentially aliased, emit into a temporary and then copy.

https://github.com/llvm/llvm-project/pull/101038


More information about the cfe-commits mailing list