Skip to content
Closed
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
4 changes: 2 additions & 2 deletions src/intrinsics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,7 @@ static jl_cgval_t emit_pointerref(jl_codectx_t &ctx, jl_cgval_t *argv)
ai.decorateInst(load);
return mark_julia_type(ctx, load, true, ety);
}
else if (!jl_isbits(ety)) {
else if (!jl_is_immutable(ety)) {
assert(jl_is_datatype(ety));
uint64_t size = jl_datatype_size(ety);
Value *strct = emit_allocobj(ctx, (jl_datatype_t*)ety);
Expand Down Expand Up @@ -775,7 +775,7 @@ static jl_cgval_t emit_pointerset(jl_codectx_t &ctx, jl_cgval_t *argv)
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_data);
ai.decorateInst(store);
}
else if (!jl_isbits(ety)) {
else if (!jl_is_immutable(ety)) {
thePtr = emit_unbox(ctx, getInt8PtrTy(ctx.builder.getContext()), e, e.typ);
uint64_t size = jl_datatype_size(ety);
im1 = ctx.builder.CreateMul(im1, ConstantInt::get(ctx.types().T_size,
Expand Down
18 changes: 18 additions & 0 deletions test/intrinsics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ end
struct GhostStruct end
@test unsafe_load(Ptr{GhostStruct}(rand(Int))) === GhostStruct()

# issue #50243
struct ImmutableNonIsBits
v::Vector{Int}
end
const ref50243 = Ref(ImmutableNonIsBits([1,2,3]))
load50243() = unsafe_load(Ptr{ImmutableNonIsBits}(pointer_from_objref(ref50243)))
sum50243() = sum(load50243().v) # (Do something with v to prevent the compiler from eliding)
@test load50243() === ref50243[]
@test sum50243() === 6
@test @allocated(sum50243()) === 0

const ref50243 = Ref(ImmutableNonIsBits([1,2,3]))
store50243!(v2) = unsafe_store!(Ptr{ImmutableNonIsBits}(pointer_from_objref(ref50243)), v2)
new50243 = ImmutableNonIsBits([1])
store50243!(new50243)
@test ref50243[] === new50243
@test @allocated(store50243!(ref50243[])) === 0

# macro to verify and compare the compiled output of an intrinsic with its runtime version
macro test_intrinsic(intr, args...)
output = args[end]
Expand Down