Skip to content

Commit 2cce5a4

Browse files
gbaraldiclaude
andcommitted
Ensure byref attribute is preserved on rewritten parameters
The byref TypeAttribute may be dropped when copying attributes to the new function with changed parameter types (ptr -> ptr addrspace(4)). Explicitly re-add it to ensure the AMDGPU backend knows the kernarg contains the struct data inline, not a pointer to it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5e07342 commit 2cce5a4

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/gcn.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,17 @@ function rewrite_byref_addrspaces!(@nospecialize(job::CompilerJob{GCNCompilerTar
9292
LLVM.name!(new_arg, LLVM.name(arg))
9393
end
9494

95-
# copy parameter attributes
95+
# copy parameter attributes, ensuring byref is preserved with correct type
9696
for (i, _) in enumerate(parameters(ft))
9797
for attr in collect(parameter_attributes(f, i))
9898
push!(parameter_attributes(new_f, i), attr)
9999
end
100+
# explicitly re-add byref with the correct type, in case the copy
101+
# dropped it due to the parameter type change
102+
if byref[i]
103+
llvm_typ = convert(LLVMType, byref_types[i])
104+
push!(parameter_attributes(new_f, i), TypeAttribute("byref", llvm_typ))
105+
end
100106
end
101107

102108
# load byref arguments from addrspace(4) into local allocas

0 commit comments

Comments
 (0)