Skip to content

Commit

Permalink
codegen: handle dead code with unsafe_store of FCA pointers (#50164)
Browse files Browse the repository at this point in the history
Fix #50125
  • Loading branch information
vtjnash authored Jun 22, 2023
1 parent ad120f4 commit ef6d900
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 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 (!deserves_stack(ety)) {
assert(jl_is_datatype(ety));
uint64_t size = jl_datatype_size(ety);
Value *strct = emit_allocobj(ctx, (jl_datatype_t*)ety);
Expand All @@ -716,7 +716,7 @@ static jl_cgval_t emit_pointerref(jl_codectx_t &ctx, jl_cgval_t *argv)
assert(!isboxed);
if (!type_is_ghost(ptrty)) {
Value *thePtr = emit_unbox(ctx, ptrty->getPointerTo(), e, e.typ);
auto load = typed_load(ctx, thePtr, im1, ety, ctx.tbaa().tbaa_data, nullptr, isboxed, AtomicOrdering::NotAtomic, true, align_nb);
auto load = typed_load(ctx, thePtr, im1, ety, ctx.tbaa().tbaa_data, nullptr, isboxed, AtomicOrdering::NotAtomic, false, align_nb);
setName(ctx.emission_context, load.V, "pointerref");
return load;
}
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 (x.ispointer()) {
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 Expand Up @@ -852,7 +852,7 @@ static jl_cgval_t emit_atomic_pointerref(jl_codectx_t &ctx, jl_cgval_t *argv)
return jl_cgval_t();
}

if (!jl_isbits(ety)) {
if (!deserves_stack(ety)) {
assert(jl_is_datatype(ety));
Value *strct = emit_allocobj(ctx, (jl_datatype_t*)ety);
setName(ctx.emission_context, strct, "atomic_pointerref_box");
Expand All @@ -876,7 +876,7 @@ static jl_cgval_t emit_atomic_pointerref(jl_codectx_t &ctx, jl_cgval_t *argv)
assert(!isboxed);
if (!type_is_ghost(ptrty)) {
Value *thePtr = emit_unbox(ctx, ptrty->getPointerTo(), e, e.typ);
auto load = typed_load(ctx, thePtr, nullptr, ety, ctx.tbaa().tbaa_data, nullptr, isboxed, llvm_order, true, nb);
auto load = typed_load(ctx, thePtr, nullptr, ety, ctx.tbaa().tbaa_data, nullptr, isboxed, llvm_order, false, nb);
setName(ctx.emission_context, load.V, "atomic_pointerref");
return load;
}
Expand Down Expand Up @@ -954,6 +954,7 @@ static jl_cgval_t emit_atomic_pointerop(jl_codectx_t &ctx, intrinsic f, const jl
}

if (!jl_isbits(ety)) {
//if (!deserves_stack(ety))
//Value *thePtr = emit_unbox(ctx, getInt8PtrTy(ctx.builder.getContext()), e, e.typ);
//uint64_t size = jl_datatype_size(ety);
return emit_runtime_call(ctx, f, argv, nargs); // TODO: optimizations
Expand Down

0 comments on commit ef6d900

Please sign in to comment.