[clang] [clang] Limit lifetimes of temporaries to the full expression (PR #170517)
Paul Kirth via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 3 13:55:15 PST 2025
================
@@ -4947,7 +4948,23 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E,
return;
}
- args.add(EmitAnyExprToTemp(E), type);
+ AggValueSlot ArgSlot = AggValueSlot::ignored();
+ // If the callee returns a reference, skip this stack saving optimization;
----------------
ilovepi wrote:
This was brought up in https://reviews.llvm.org/D74094. In a complex expression, a reference to the temporary could be returned (e.g. passed in via a parameter and back out via return) and which is then used in another part of the expression.
I left that logic (and comment) in place from the original patch, since it seems to be to be conservative w.r.t. preserving the status quo.
https://github.com/llvm/llvm-project/pull/170517
More information about the cfe-commits
mailing list