Expand Julia's atomic modify pseudo-intrinsic - #945
Merged
Merged
Conversation
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.
vchuravy
approved these changes
Sep 24, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since Julia 1.13 (JuliaLang/julia#57010), codegen emits atomic modifications such as
@atomic x.f += 1as calls to thejulia.atomicmodifypseudo-intrinsic, which Julia's own pipeline expands after GC lowering withExpandAtomicModifyPass. 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: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
@atomicfield modification in a kernel, from JuliaGPU/Metal.jl#977) pass on 1.13.