Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/optim.jl
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ function buildIntrinsicLoweringPipeline(mpm, @nospecialize(job::CompilerJob), op
if uses_julia_runtime(job) && VERSION >= v"1.11.0-DEV.208"
add!(fpm, FinalLowerGCPass())
end
# codegen emits atomic modifications (e.g. `@atomic x.f += 1`) as calls to the
# `julia.atomicmodify` pseudo-intrinsic, which Julia expands after GC lowering
# (JuliaLang/julia#57010)
@static if VERSION >= v"1.13.0-DEV.321"
add!(fpm, ExpandAtomicModifyPass())
end
end
if uses_julia_runtime(job) && VERSION < v"1.11.0-DEV.208"
add!(mpm, FinalLowerGCPass())
Expand Down
19 changes: 19 additions & 0 deletions test/native.jl
Original file line number Diff line number Diff line change
Expand Up @@ -765,6 +765,25 @@ end
end
end

@testset "atomic field modifications" begin
# from Julia 1.13, `@atomic x.f += 1` is a call to the `julia.atomicmodify`
# pseudo-intrinsic, which has to be expanded (JuliaLang/julia#57010)
mod = @eval module $(gensym())
mutable struct Counter
@atomic n::Int
end
function increment(c::Counter)
@atomic c.n += 1
return
end
end

@test @filecheck implicit_check_not=["julia.atomicmodify"] begin
@check "{{atomicrmw add|cmpxchg}}"
Native.code_llvm(mod.increment, Tuple{mod.Counter})
end
end

@testset "tracked pointers" begin
mod = @eval module $(gensym())
function kernel(a)
Expand Down
Loading