[clang] [clang][CodeGen] Set `dead_on_return` on indirect pointer arguments (PR #148159)
Antonio Frighetto via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 15 10:58:42 PDT 2025
================
@@ -2852,8 +2852,21 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
if (AI.getInReg())
Attrs.addAttribute(llvm::Attribute::InReg);
- if (AI.getIndirectByVal())
+ // Depending on the ABI, this may be either a byval or a dead_on_return
+ // argument.
+ if (AI.getIndirectByVal()) {
Attrs.addByValAttr(getTypes().ConvertTypeForMem(ParamType));
+ } else {
+ // Add dead_on_return when the object's lifetime ends in the callee.
+ // This includes trivially-destructible C++ objects, as well as objects
+ // whose destruction / clean-up is carried out within the callee (e.g.,
+ // Obj-C++ ARC-managed structs, MSVC callee-destroyed objects).
----------------
antoniofrighetto wrote:
Oh, sure thing, thanks!
https://github.com/llvm/llvm-project/pull/148159
More information about the cfe-commits
mailing list