Skip to content

Expand Julia's atomic modify pseudo-intrinsic - #945

Merged
maleadt merged 1 commit into
mainfrom
tb/expand-atomic-modify
Sep 25, 2026
Merged

maleadt merged 1 commit into
mainfrom
tb/expand-atomic-modify

Conversation

@maleadt

@maleadt maleadt commented Sep 24, 2026

Copy link
Copy Markdown
Member

Since Julia 1.13 (JuliaLang/julia#57010), codegen emits atomic modifications such as @atomic x.f += 1 as calls to the julia.atomicmodify pseudo-intrinsic, which Julia's own pipeline expands after GC lowering with ExpandAtomicModifyPass. GPUCompiler builds its own GC-lowering pipeline and didn't run that pass, so the call survived into the final IR. For GPU targets, validation rejects that as a call to an unknown function:

Reason: unsupported call to an unknown function (call to julia.atomicmodify.i32.p11)
Stacktrace:
 [1] modifyproperty!
   @ ./Base_compiler.jl:97

This PR adds the pass right after the GC lowering, as Julia does. The new native test fails on 1.13 without the fix and passes with it; on 1.12 and 1.10 it passes either way. With this change, Metal.jl's atomics tests (including an @atomic field modification in a kernel, from JuliaGPU/Metal.jl#977) pass on 1.13.

From Julia 1.13, codegen emits atomic modifications (e.g. `@atomic x.f += 1`)
as calls to `julia.atomicmodify`, which Julia's pipeline expands after GC
lowering with `ExpandAtomicModifyPass` (JuliaLang/julia#57010). Our
pipeline didn't, so the call survived and failed validation as a call to
an unknown function.
@maleadt
maleadt merged commit 8496909 into main Sep 25, 2026
32 of 33 checks passed
@maleadt
maleadt deleted the tb/expand-atomic-modify branch September 25, 2026 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants