Skip to content

Commit b08a764

Browse files
gbaraldiclaude
andcommitted
Detect byref params via attribute instead of classify_arguments
classify_arguments can fail post-optimization on typed-pointer LLVM because convert(LLVMType, source_typ) may produce a different element type than the post-optimization codegen type, hitting the assertion at irgen.jl:322. This was triggered by the Symbols test in AMDGPU.jl. Instead of re-classifying arguments, just check for the byref attribute directly on each parameter — we know it's present because irgen.jl added it. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 687f79d commit b08a764

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/gcn.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,14 +95,14 @@ function add_kernarg_address_spaces!(
9595
)
9696
ft = function_type(f)
9797

98-
# find the byref parameters
98+
# find the byref parameters by checking for the byref attribute directly,
99+
# rather than re-classifying arguments (which can fail on typed-pointer LLVM
100+
# due to element type mismatches in classify_arguments assertions).
101+
byref_kind = LLVM.API.LLVMGetEnumAttributeKindForName("byref", 5)
99102
byref_mask = BitVector(undef, length(parameters(ft)))
100-
args = classify_arguments(job, ft; post_optimization = job.config.optimize)
101-
filter!(args) do arg
102-
arg.cc != GHOST
103-
end
104-
for arg in args
105-
byref_mask[arg.idx] = (arg.cc == BITS_REF || arg.cc == KERNEL_STATE)
103+
for i in 1:length(parameters(ft))
104+
attrs = collect(parameter_attributes(f, i))
105+
byref_mask[i] = any(a -> a isa TypeAttribute && kind(a) == byref_kind, attrs)
106106
end
107107

108108
# check if any flat pointer byref params need rewriting

0 commit comments

Comments
 (0)