Skip to content

Commit 55c40ce

Browse files
authored
move null check in unsafe_convert of RefValue (#55766)
LLVM can optimize out this check but our optimizer can't, so this leads to smaller IR in most cases.
1 parent a993cd8 commit 55c40ce

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

base/refvalue.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ function unsafe_convert(P::Union{Type{Ptr{T}},Type{Ptr{Cvoid}}}, b::RefValue{T})
4646
# Instead, explicitly load the pointer from the `RefValue`,
4747
# which also ensures this returns same pointer as the one rooted in the `RefValue` object.
4848
p = atomic_pointerref(Ptr{Ptr{Cvoid}}(pointer_from_objref(b)), :monotonic)
49-
end
50-
if p == C_NULL
51-
throw(UndefRefError())
49+
if p == C_NULL
50+
throw(UndefRefError())
51+
end
5252
end
5353
return p
5454
end

0 commit comments

Comments
 (0)