Skip to content

Commit 309b1b1

Browse files
authored
codegen: gc wb for atomic FCA stores (#58792)
Need to re-load the correct `r` since issetfield skips the intcast, resulting in no gc wb for the FCA. Fix #58760
1 parent 4ae3f5e commit 309b1b1

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

Compiler/test/codegen.jl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,3 +1069,9 @@ let io = IOBuffer()
10691069
str = String(take!(io))
10701070
@test !occursin("jtbaa_unionselbyte", str)
10711071
end
1072+
1073+
let io = IOBuffer()
1074+
code_llvm(io, (x, y) -> (@atomic x[1] = y; nothing), (AtomicMemory{Pair{Any,Any}}, Pair{Any,Any},), raw=true, optimize=false)
1075+
str = String(take!(io))
1076+
@test occursin("julia.write_barrier", str)
1077+
end

src/cgutils.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2683,6 +2683,11 @@ static jl_cgval_t typed_store(jl_codectx_t &ctx,
26832683
ctx.builder.CreateStore(r, intcast);
26842684
r = ctx.builder.CreateLoad(intcast_eltyp, intcast);
26852685
}
2686+
else if (!isboxed && intcast_eltyp) {
2687+
assert(issetfield);
2688+
// issetfield doesn't use intcast, so need to reload rhs with the correct type
2689+
r = emit_unbox(ctx, intcast_eltyp, rhs, jltype);
2690+
}
26862691
if (!isboxed)
26872692
emit_write_multibarrier(ctx, parent, r, rhs.typ);
26882693
else

0 commit comments

Comments
 (0)