@@ -1425,10 +1425,10 @@ static bool emit_getfield_unknownidx(jl_codectx_t &ctx,
1425
1425
Value *idx, jl_datatype_t *stt, jl_value_t *inbounds)
1426
1426
{
1427
1427
size_t nfields = jl_datatype_nfields (stt);
1428
+ bool maybe_null = (unsigned )stt->ninitialized != nfields;
1428
1429
if (strct.ispointer ()) { // boxed or stack
1429
1430
if (is_datatype_all_pointers (stt)) {
1430
1431
idx = emit_bounds_check (ctx, strct, (jl_value_t *)stt, idx, ConstantInt::get (T_size, nfields), inbounds);
1431
- bool maybe_null = (unsigned )stt->ninitialized != nfields;
1432
1432
size_t minimum_field_size = std::numeric_limits<size_t >::max ();
1433
1433
size_t minimum_align = JL_HEAP_ALIGNMENT;
1434
1434
for (size_t i = 0 ; i < nfields; ++i) {
@@ -1458,7 +1458,7 @@ static bool emit_getfield_unknownidx(jl_codectx_t &ctx,
1458
1458
jl_value_t *jt = jl_field_type (stt, 0 );
1459
1459
idx = emit_bounds_check (ctx, strct, (jl_value_t *)stt, idx, ConstantInt::get (T_size, nfields), inbounds);
1460
1460
Value *ptr = maybe_decay_tracked (data_pointer (ctx, strct));
1461
- if (!stt->mutabl ) {
1461
+ if (!stt->mutabl && !(maybe_null && jt == ( jl_value_t *)jl_bool_type) ) {
1462
1462
// just compute the pointer and let user load it when necessary
1463
1463
Type *fty = julia_type_to_llvm (jt);
1464
1464
Value *addr = ctx.builder .CreateInBoundsGEP (fty, emit_bitcast (ctx, ptr, PointerType::get (fty, 0 )), idx);
@@ -1512,6 +1512,7 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
1512
1512
if (type_is_ghost (elty))
1513
1513
return ghostValue (jfty);
1514
1514
Value *fldv = NULL ;
1515
+ bool maybe_null = idx >= (unsigned )jt->ninitialized ;
1515
1516
if (strct.ispointer ()) {
1516
1517
Value *staddr = maybe_decay_tracked (data_pointer (ctx, strct));
1517
1518
bool isboxed;
@@ -1553,7 +1554,6 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
1553
1554
}
1554
1555
unsigned align = jl_field_align (jt, idx);
1555
1556
if (jl_field_isptr (jt, idx)) {
1556
- bool maybe_null = idx >= (unsigned )jt->ninitialized ;
1557
1557
Instruction *Load = maybe_mark_load_dereferenceable (
1558
1558
ctx.builder .CreateLoad (T_prjlvalue, emit_bitcast (ctx, addr, T_pprjlvalue)),
1559
1559
maybe_null, jl_field_type (jt, idx));
@@ -1586,7 +1586,7 @@ static jl_cgval_t emit_getfield_knownidx(jl_codectx_t &ctx, const jl_cgval_t &st
1586
1586
}
1587
1587
return mark_julia_slot (addr, jfty, tindex, strct.tbaa );
1588
1588
}
1589
- else if (!jt->mutabl ) {
1589
+ else if (!jt->mutabl && !(maybe_null && jfty == ( jl_value_t *)jl_bool_type) ) {
1590
1590
// just compute the pointer and let user load it when necessary
1591
1591
return mark_julia_slot (addr, jfty, NULL , strct.tbaa );
1592
1592
}
0 commit comments