@@ -1657,7 +1657,7 @@ static MDNode *best_tbaa(jl_tbaacache_t &tbaa_cache, jl_value_t *jt) {
1657
1657
// note that this includes jl_isbits, although codegen should work regardless
1658
1658
static bool jl_is_concrete_immutable (jl_value_t * t)
1659
1659
{
1660
- return jl_is_immutable_datatype (t) && ((jl_datatype_t *)t)->isconcretetype ;
1660
+ return jl_may_be_immutable_datatype (t) && ((jl_datatype_t *)t)->isconcretetype ;
1661
1661
}
1662
1662
1663
1663
static bool jl_is_pointerfree (jl_value_t * t)
@@ -7355,8 +7355,8 @@ static Function *gen_cfun_wrapper(
7355
7355
inputarg = mark_julia_type (ctx, val, false , jargty);
7356
7356
}
7357
7357
}
7358
- else if (static_at || (!jl_is_typevar (jargty) && ! jl_is_immutable_datatype (jargty))) {
7359
- // must be a jl_value_t* (because it's mutable or contains gc roots )
7358
+ else if (static_at || (!jl_is_typevar (jargty) && (! jl_is_datatype (jargty) || jl_is_abstracttype (jargty) || jl_is_mutable_datatype (jargty) ))) {
7359
+ // must be a jl_value_t* (because it is mutable or abstract )
7360
7360
inputarg = mark_julia_type (ctx, maybe_decay_untracked (ctx, val), true , jargty_proper);
7361
7361
}
7362
7362
else {
@@ -7370,31 +7370,36 @@ static Function *gen_cfun_wrapper(
7370
7370
emit_ptrgep (ctx, nestPtr, jl_array_nrows (*closure_types) * ctx.types ().sizeof_ptr ),
7371
7371
Align (sizeof (void *)));
7372
7372
BasicBlock *boxedBB = BasicBlock::Create (ctx.builder .getContext (), " isboxed" , cw);
7373
- BasicBlock *loadBB = BasicBlock::Create (ctx.builder .getContext (), " need-load " , cw);
7373
+ BasicBlock *notanyBB = BasicBlock::Create (ctx.builder .getContext (), " not-any " , cw);
7374
7374
BasicBlock *unboxedBB = BasicBlock::Create (ctx.builder .getContext (), " maybe-unboxed" , cw);
7375
7375
BasicBlock *isanyBB = BasicBlock::Create (ctx.builder .getContext (), " any" , cw);
7376
7376
BasicBlock *afterBB = BasicBlock::Create (ctx.builder .getContext (), " after" , cw);
7377
- Value *isrtboxed = ctx.builder .CreateIsNull (val); // XXX: this is the wrong condition and should be inspecting runtime_dt instead
7378
- ctx.builder .CreateCondBr (isrtboxed, boxedBB, loadBB);
7379
- ctx.builder .SetInsertPoint (boxedBB);
7380
- Value *p1 = val;
7381
- p1 = track_pjlvalue (ctx, p1);
7382
- ctx.builder .CreateBr (afterBB);
7383
- ctx.builder .SetInsertPoint (loadBB);
7384
7377
Value *isrtany = ctx.builder .CreateICmpEQ (
7385
- literal_pointer_val (ctx, (jl_value_t *)jl_any_type), val );
7386
- ctx.builder .CreateCondBr (isrtany, isanyBB, unboxedBB );
7378
+ track_pjlvalue (ctx, literal_pointer_val (ctx, (jl_value_t *)jl_any_type)), runtime_dt );
7379
+ ctx.builder .CreateCondBr (isrtany, isanyBB, notanyBB );
7387
7380
ctx.builder .SetInsertPoint (isanyBB);
7388
- Value *p2 = ctx.builder .CreateAlignedLoad (ctx.types ().T_prjlvalue , val, Align (sizeof (void *)));
7381
+ Value *p1 = ctx.builder .CreateAlignedLoad (ctx.types ().T_prjlvalue , val, Align (sizeof (void *)));
7382
+ ctx.builder .CreateBr (afterBB);
7383
+ isanyBB = ctx.builder .GetInsertBlock (); // could have changed
7384
+ ctx.builder .SetInsertPoint (notanyBB);
7385
+ jl_cgval_t runtime_dt_val = mark_julia_type (ctx, runtime_dt, true , jl_any_type);
7386
+ Value *isrtboxed = // (!jl_is_datatype(runtime_dt) || !jl_is_concrete_datatype(runtime_dt) || jl_is_mutable_datatype(runtime_dt))
7387
+ emit_guarded_test (ctx, emit_exactly_isa (ctx, runtime_dt_val, jl_datatype_type), true , [&] {
7388
+ return ctx.builder .CreateOr (ctx.builder .CreateNot (emit_isconcrete (ctx, runtime_dt)), emit_datatype_mutabl (ctx, runtime_dt));
7389
+ });
7390
+ ctx.builder .CreateCondBr (isrtboxed, boxedBB, unboxedBB);
7391
+ ctx.builder .SetInsertPoint (boxedBB);
7392
+ Value *p2 = track_pjlvalue (ctx, val);
7389
7393
ctx.builder .CreateBr (afterBB);
7394
+ boxedBB = ctx.builder .GetInsertBlock (); // could have changed
7390
7395
ctx.builder .SetInsertPoint (unboxedBB);
7391
7396
Value *p3 = emit_new_bits (ctx, runtime_dt, val);
7392
7397
unboxedBB = ctx.builder .GetInsertBlock (); // could have changed
7393
7398
ctx.builder .CreateBr (afterBB);
7394
7399
ctx.builder .SetInsertPoint (afterBB);
7395
7400
PHINode *p = ctx.builder .CreatePHI (ctx.types ().T_prjlvalue , 3 );
7396
- p->addIncoming (p1, boxedBB );
7397
- p->addIncoming (p2, isanyBB );
7401
+ p->addIncoming (p1, isanyBB );
7402
+ p->addIncoming (p2, boxedBB );
7398
7403
p->addIncoming (p3, unboxedBB);
7399
7404
inputarg = mark_julia_type (ctx, p, true , jargty_proper);
7400
7405
}
@@ -7939,7 +7944,7 @@ static jl_returninfo_t get_specsig_function(jl_codegen_params_t ¶ms, Module
7939
7944
param.addAttribute (Attribute::ReadOnly);
7940
7945
ty = PointerType::get (M->getContext (), AddressSpace::Derived);
7941
7946
}
7942
- else if (isboxed && jl_is_immutable_datatype (jt)) {
7947
+ else if (isboxed && jl_may_be_immutable_datatype (jt) && ! jl_is_abstracttype (jt)) {
7943
7948
param.addAttribute (Attribute::ReadOnly);
7944
7949
}
7945
7950
else if (jl_is_primitivetype (jt) && ty->isIntegerTy ()) {
0 commit comments