Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

codegen: handle dead code with unsafe_store of FCA pointers #50164

Merged
merged 2 commits into from
Jun 22, 2023
Merged
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
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