Skip to content

Commit 9cc22e3

Browse files
gbaraldiclaude
andcommitted
Pass TargetMachine to InferAddressSpaces in finish_ir! cleanup
InferAddressSpaces needs TargetTransformInfo to determine the flat address space (0 on AMDGPU). Without passing a TargetMachine, the pass has no TTI and skips all promotions. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 1c20647 commit 9cc22e3

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/gcn.jl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ function add_kernarg_address_spaces!(@nospecialize(job::CompilerJob), mod::LLVM.
152152
erase!(f)
153153
LLVM.name!(new_f, fn)
154154

155-
# propagate addrspace(4) through GEPs and loads, then clean up
155+
# propagate addrspace(4) through GEPs and loads, then clean up.
156+
# InferAddressSpaces needs TargetTransformInfo (via TargetMachine) to know
157+
# that flat address space is 0 on AMDGPU.
158+
tm = llvm_machine(job.config.target)
156159
@dispose pb=NewPMPassBuilder() begin
157160
add!(pb, NewPMFunctionPassManager()) do fpm
158161
add!(fpm, InferAddressSpacesPass())
@@ -163,8 +166,9 @@ function add_kernarg_address_spaces!(@nospecialize(job::CompilerJob), mod::LLVM.
163166
add!(fpm, EarlyCSEPass())
164167
add!(fpm, InstCombinePass())
165168
end
166-
run!(pb, mod)
169+
run!(pb, mod, tm)
167170
end
171+
dispose(tm)
168172

169173
return functions(mod)[fn]
170174
end

0 commit comments

Comments
 (0)