@@ -1600,7 +1600,7 @@ static MDNode *best_tbaa(jl_tbaacache_t &tbaa_cache, jl_value_t *jt) {
1600
1600
// note that this includes jl_isbits, although codegen should work regardless
1601
1601
static bool jl_is_concrete_immutable (jl_value_t * t)
1602
1602
{
1603
- return jl_is_immutable_datatype (t) && ((jl_datatype_t *)t)->isconcretetype ;
1603
+ return jl_may_be_immutable_datatype (t) && ((jl_datatype_t *)t)->isconcretetype ;
1604
1604
}
1605
1605
1606
1606
static bool jl_is_pointerfree (jl_value_t * t)
@@ -7385,8 +7385,8 @@ static Function *gen_cfun_wrapper(
7385
7385
inputarg = mark_julia_type (ctx, val, false , jargty);
7386
7386
}
7387
7387
}
7388
- else if (static_at || (!jl_is_typevar (jargty) && ! jl_is_immutable_datatype (jargty))) {
7389
- // must be a jl_value_t* (because it's mutable or contains gc roots )
7388
+ else if (static_at || (!jl_is_typevar (jargty) && (! jl_is_datatype (jargty) || jl_is_abstracttype (jargty) || jl_is_mutable_datatype (jargty) ))) {
7389
+ // must be a jl_value_t* (because it is mutable or abstract )
7390
7390
inputarg = mark_julia_type (ctx, maybe_decay_untracked (ctx, val), true , jargty_proper);
7391
7391
}
7392
7392
else {
@@ -7400,31 +7400,36 @@ static Function *gen_cfun_wrapper(
7400
7400
emit_ptrgep (ctx, nestPtr, jl_array_nrows (*closure_types) * ctx.types ().sizeof_ptr ),
7401
7401
Align (sizeof (void *)));
7402
7402
BasicBlock *boxedBB = BasicBlock::Create (ctx.builder .getContext (), " isboxed" , cw);
7403
- BasicBlock *loadBB = BasicBlock::Create (ctx.builder .getContext (), " need-load " , cw);
7403
+ BasicBlock *notanyBB = BasicBlock::Create (ctx.builder .getContext (), " not-any " , cw);
7404
7404
BasicBlock *unboxedBB = BasicBlock::Create (ctx.builder .getContext (), " maybe-unboxed" , cw);
7405
7405
BasicBlock *isanyBB = BasicBlock::Create (ctx.builder .getContext (), " any" , cw);
7406
7406
BasicBlock *afterBB = BasicBlock::Create (ctx.builder .getContext (), " after" , cw);
7407
- Value *isrtboxed = ctx.builder .CreateIsNull (val); // XXX: this is the wrong condition and should be inspecting runtime_dt instead
7408
- ctx.builder .CreateCondBr (isrtboxed, boxedBB, loadBB);
7409
- ctx.builder .SetInsertPoint (boxedBB);
7410
- Value *p1 = val;
7411
- p1 = track_pjlvalue (ctx, p1);
7412
- ctx.builder .CreateBr (afterBB);
7413
- ctx.builder .SetInsertPoint (loadBB);
7414
7407
Value *isrtany = ctx.builder .CreateICmpEQ (
7415
- literal_pointer_val (ctx, (jl_value_t *)jl_any_type), val );
7416
- ctx.builder .CreateCondBr (isrtany, isanyBB, unboxedBB );
7408
+ track_pjlvalue (ctx, literal_pointer_val (ctx, (jl_value_t *)jl_any_type)), runtime_dt );
7409
+ ctx.builder .CreateCondBr (isrtany, isanyBB, notanyBB );
7417
7410
ctx.builder .SetInsertPoint (isanyBB);
7418
- Value *p2 = ctx.builder .CreateAlignedLoad (ctx.types ().T_prjlvalue , val, Align (sizeof (void *)));
7411
+ Value *p1 = ctx.builder .CreateAlignedLoad (ctx.types ().T_prjlvalue , val, Align (sizeof (void *)));
7412
+ ctx.builder .CreateBr (afterBB);
7413
+ isanyBB = ctx.builder .GetInsertBlock (); // could have changed
7414
+ ctx.builder .SetInsertPoint (notanyBB);
7415
+ jl_cgval_t runtime_dt_val = mark_julia_type (ctx, runtime_dt, true , jl_any_type);
7416
+ Value *isrtboxed = // (!jl_is_datatype(runtime_dt) || !jl_is_concrete_datatype(runtime_dt) || jl_is_mutable_datatype(runtime_dt))
7417
+ emit_guarded_test (ctx, emit_exactly_isa (ctx, runtime_dt_val, jl_datatype_type), true , [&] {
7418
+ return ctx.builder .CreateOr (ctx.builder .CreateNot (emit_isconcrete (ctx, runtime_dt)), emit_datatype_mutabl (ctx, runtime_dt));
7419
+ });
7420
+ ctx.builder .CreateCondBr (isrtboxed, boxedBB, unboxedBB);
7421
+ ctx.builder .SetInsertPoint (boxedBB);
7422
+ Value *p2 = track_pjlvalue (ctx, val);
7419
7423
ctx.builder .CreateBr (afterBB);
7424
+ boxedBB = ctx.builder .GetInsertBlock (); // could have changed
7420
7425
ctx.builder .SetInsertPoint (unboxedBB);
7421
7426
Value *p3 = emit_new_bits (ctx, runtime_dt, val);
7422
7427
unboxedBB = ctx.builder .GetInsertBlock (); // could have changed
7423
7428
ctx.builder .CreateBr (afterBB);
7424
7429
ctx.builder .SetInsertPoint (afterBB);
7425
7430
PHINode *p = ctx.builder .CreatePHI (ctx.types ().T_prjlvalue , 3 );
7426
- p->addIncoming (p1, boxedBB );
7427
- p->addIncoming (p2, isanyBB );
7431
+ p->addIncoming (p1, isanyBB );
7432
+ p->addIncoming (p2, boxedBB );
7428
7433
p->addIncoming (p3, unboxedBB);
7429
7434
inputarg = mark_julia_type (ctx, p, true , jargty_proper);
7430
7435
}
@@ -7975,7 +7980,7 @@ static jl_returninfo_t get_specsig_function(jl_codegen_params_t ¶ms, Module
7975
7980
param.addAttribute (Attribute::ReadOnly);
7976
7981
ty = PointerType::get (M->getContext (), AddressSpace::Derived);
7977
7982
}
7978
- else if (isboxed && jl_is_immutable_datatype (jt)) {
7983
+ else if (isboxed && jl_may_be_immutable_datatype (jt) && ! jl_is_abstracttype (jt)) {
7979
7984
param.addAttribute (Attribute::ReadOnly);
7980
7985
}
7981
7986
else if (jl_is_primitivetype (jt) && ty->isIntegerTy ()) {
0 commit comments