[clang] [HLSL] Avoid putting the byval attribute on out and inout parameters (PR #150495)
Sarah Spall via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 24 13:10:47 PDT 2025
================
@@ -2852,20 +2852,28 @@ void CodeGenModule::ConstructAttributeList(StringRef Name,
if (AI.getInReg())
Attrs.addAttribute(llvm::Attribute::InReg);
- // 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 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).
- if (!ParamType.isDestructedType() || !ParamType->isRecordType() ||
- ParamType->castAs<RecordType>()
- ->getDecl()
- ->isParamDestroyedInCallee())
- Attrs.addAttribute(llvm::Attribute::DeadOnReturn);
+ // HLSL out and inout parameters must not be marked with ByVal or
----------------
spall wrote:
Maybe expand this comment to explain why it isn't byval
"HLSL out/inout parameters are not ByVal because the caller is meant to see the callees changes"
https://github.com/llvm/llvm-project/pull/150495
More information about the cfe-commits
mailing list