Skip to content

Commit 016cb5f

Browse files
vtjnashKristofferC
authored andcommitted
codegen: handle dead code with unsafe_store of FCA pointers (#50164)
Fix #50125 (cherry picked from commit ef6d900)
1 parent 5f465da commit 016cb5f

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/intrinsics.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ static jl_cgval_t emit_pointerref(jl_codectx_t &ctx, jl_cgval_t *argv)
678678
ai.decorateInst(load);
679679
return mark_julia_type(ctx, load, true, ety);
680680
}
681-
else if (!jl_isbits(ety)) {
681+
else if (!deserves_stack(ety)) {
682682
assert(jl_is_datatype(ety));
683683
uint64_t size = jl_datatype_size(ety);
684684
Value *strct = emit_allocobj(ctx, size,
@@ -697,7 +697,7 @@ static jl_cgval_t emit_pointerref(jl_codectx_t &ctx, jl_cgval_t *argv)
697697
assert(!isboxed);
698698
if (!type_is_ghost(ptrty)) {
699699
Value *thePtr = emit_unbox(ctx, ptrty->getPointerTo(), e, e.typ);
700-
return typed_load(ctx, thePtr, im1, ety, ctx.tbaa().tbaa_data, nullptr, isboxed, AtomicOrdering::NotAtomic, true, align_nb);
700+
return typed_load(ctx, thePtr, im1, ety, ctx.tbaa().tbaa_data, nullptr, isboxed, AtomicOrdering::NotAtomic, false, align_nb);
701701
}
702702
else {
703703
return ghostValue(ctx, ety);
@@ -751,7 +751,7 @@ static jl_cgval_t emit_pointerset(jl_codectx_t &ctx, jl_cgval_t *argv)
751751
jl_aliasinfo_t ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_data);
752752
ai.decorateInst(store);
753753
}
754-
else if (!jl_isbits(ety)) {
754+
else if (x.ispointer()) {
755755
thePtr = emit_unbox(ctx, getInt8PtrTy(ctx.builder.getContext()), e, e.typ);
756756
uint64_t size = jl_datatype_size(ety);
757757
im1 = ctx.builder.CreateMul(im1, ConstantInt::get(getSizeTy(ctx.builder.getContext()),
@@ -824,7 +824,7 @@ static jl_cgval_t emit_atomic_pointerref(jl_codectx_t &ctx, jl_cgval_t *argv)
824824
return jl_cgval_t();
825825
}
826826

827-
if (!jl_isbits(ety)) {
827+
if (!deserves_stack(ety)) {
828828
assert(jl_is_datatype(ety));
829829
uint64_t size = jl_datatype_size(ety);
830830
Value *strct = emit_allocobj(ctx, size,
@@ -848,7 +848,7 @@ static jl_cgval_t emit_atomic_pointerref(jl_codectx_t &ctx, jl_cgval_t *argv)
848848
assert(!isboxed);
849849
if (!type_is_ghost(ptrty)) {
850850
Value *thePtr = emit_unbox(ctx, ptrty->getPointerTo(), e, e.typ);
851-
return typed_load(ctx, thePtr, nullptr, ety, ctx.tbaa().tbaa_data, nullptr, isboxed, llvm_order, true, nb);
851+
return typed_load(ctx, thePtr, nullptr, ety, ctx.tbaa().tbaa_data, nullptr, isboxed, llvm_order, false, nb);
852852
}
853853
else {
854854
if (order > jl_memory_order_monotonic)
@@ -924,6 +924,7 @@ static jl_cgval_t emit_atomic_pointerop(jl_codectx_t &ctx, intrinsic f, const jl
924924
}
925925

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

0 commit comments

Comments
 (0)