@@ -1344,7 +1344,7 @@ static MDNode *best_tbaa(jl_tbaacache_t &tbaa_cache, jl_value_t *jt) {
1344
1344
// note that this includes jl_isbits, although codegen should work regardless
1345
1345
static bool jl_is_concrete_immutable (jl_value_t * t)
1346
1346
{
1347
- return jl_may_be_immutable_datatype (t) && ((jl_datatype_t *)t)->isconcretetype ;
1347
+ return jl_is_immutable_datatype (t) && ((jl_datatype_t *)t)->isconcretetype ;
1348
1348
}
1349
1349
1350
1350
static bool jl_is_pointerfree (jl_value_t * t)
@@ -6248,9 +6248,9 @@ static Function* gen_cfun_wrapper(
6248
6248
inputarg = mark_julia_type (ctx, val, false , jargty);
6249
6249
}
6250
6250
}
6251
- else if (static_at || (!jl_is_typevar (jargty) && (! jl_is_datatype (jargty) || jl_is_abstracttype (jargty) || jl_is_mutable_datatype (jargty) ))) {
6252
- // must be a jl_value_t* (because it is mutable or abstract )
6253
- inputarg = mark_julia_type (ctx, maybe_decay_untracked (ctx, val), true , jargty_proper);
6251
+ else if (static_at || (!jl_is_typevar (jargty) && ! jl_is_immutable_datatype (jargty))) {
6252
+ // must be a jl_value_t* (because it's mutable or contains gc roots )
6253
+ inputarg = mark_julia_type (ctx, maybe_decay_untracked (ctx, emit_bitcast (ctx, val, ctx. types (). T_prjlvalue ) ), true , jargty_proper);
6254
6254
}
6255
6255
else {
6256
6256
// allocate val into a new box, if it might not be boxed
@@ -6263,36 +6263,32 @@ static Function* gen_cfun_wrapper(
6263
6263
ctx.builder .CreateConstInBoundsGEP1_32 (ctx.types ().T_prjlvalue , nestPtr, jl_array_len (*closure_types)),
6264
6264
Align (sizeof (void *)));
6265
6265
BasicBlock *boxedBB = BasicBlock::Create (ctx.builder .getContext (), " isboxed" , cw);
6266
- BasicBlock *notanyBB = BasicBlock::Create (ctx.builder .getContext (), " not-any " , cw);
6266
+ BasicBlock *loadBB = BasicBlock::Create (ctx.builder .getContext (), " need-load " , cw);
6267
6267
BasicBlock *unboxedBB = BasicBlock::Create (ctx.builder .getContext (), " maybe-unboxed" , cw);
6268
6268
BasicBlock *isanyBB = BasicBlock::Create (ctx.builder .getContext (), " any" , cw);
6269
6269
BasicBlock *afterBB = BasicBlock::Create (ctx.builder .getContext (), " after" , cw);
6270
+ Value *isrtboxed = ctx.builder .CreateIsNull (val); // XXX: this is the wrong condition and should be inspecting runtime_dt intead
6271
+ ctx.builder .CreateCondBr (isrtboxed, boxedBB, loadBB);
6272
+ ctx.builder .SetInsertPoint (boxedBB);
6273
+ Value *p1 = ctx.builder .CreateBitCast (val, ctx.types ().T_pjlvalue );
6274
+ p1 = track_pjlvalue (ctx, p1);
6275
+ ctx.builder .CreateBr (afterBB);
6276
+ ctx.builder .SetInsertPoint (loadBB);
6270
6277
Value *isrtany = ctx.builder .CreateICmpEQ (
6271
- track_pjlvalue (ctx,literal_pointer_val (ctx, (jl_value_t *)jl_any_type)), runtime_dt);
6272
- ctx.builder .CreateCondBr (isrtany, isanyBB, notanyBB);
6278
+ literal_pointer_val (ctx, (jl_value_t *)jl_any_type),
6279
+ ctx.builder .CreateBitCast (val, ctx.types ().T_pjlvalue ));
6280
+ ctx.builder .CreateCondBr (isrtany, isanyBB, unboxedBB);
6273
6281
ctx.builder .SetInsertPoint (isanyBB);
6274
- Value *p1 = ctx.builder .CreateAlignedLoad (ctx.types ().T_prjlvalue , val, Align (sizeof (void *)));
6275
- ctx.builder .CreateBr (afterBB);
6276
- isanyBB = ctx.builder .GetInsertBlock (); // could have changed
6277
- ctx.builder .SetInsertPoint (notanyBB);
6278
- jl_cgval_t runtime_dt_val = mark_julia_type (ctx, runtime_dt, true , jl_any_type);
6279
- Value *isrtboxed = // (!jl_is_datatype(runtime_dt) || !jl_is_concrete_datatype(runtime_dt) || jl_is_mutable_datatype(runtime_dt))
6280
- emit_guarded_test (ctx, emit_exactly_isa (ctx, runtime_dt_val, jl_datatype_type), true , [&] {
6281
- return ctx.builder .CreateOr (ctx.builder .CreateNot (emit_isconcrete (ctx, runtime_dt)), emit_datatype_mutabl (ctx, runtime_dt));
6282
- });
6283
- ctx.builder .CreateCondBr (isrtboxed, boxedBB, unboxedBB);
6284
- ctx.builder .SetInsertPoint (boxedBB);
6285
- Value *p2 = track_pjlvalue (ctx, val);
6282
+ Value *p2 = ctx.builder .CreateAlignedLoad (ctx.types ().T_prjlvalue , ctx.builder .CreateBitCast (val, ctx.types ().T_pprjlvalue ), Align (sizeof (void *)));
6286
6283
ctx.builder .CreateBr (afterBB);
6287
- boxedBB = ctx.builder .GetInsertBlock (); // could have changed
6288
6284
ctx.builder .SetInsertPoint (unboxedBB);
6289
6285
Value *p3 = emit_new_bits (ctx, runtime_dt, val);
6290
6286
unboxedBB = ctx.builder .GetInsertBlock (); // could have changed
6291
6287
ctx.builder .CreateBr (afterBB);
6292
6288
ctx.builder .SetInsertPoint (afterBB);
6293
6289
PHINode *p = ctx.builder .CreatePHI (ctx.types ().T_prjlvalue , 3 );
6294
- p->addIncoming (p1, isanyBB );
6295
- p->addIncoming (p2, boxedBB );
6290
+ p->addIncoming (p1, boxedBB );
6291
+ p->addIncoming (p2, isanyBB );
6296
6292
p->addIncoming (p3, unboxedBB);
6297
6293
inputarg = mark_julia_type (ctx, p, true , jargty_proper);
6298
6294
}
@@ -7073,7 +7069,7 @@ static jl_returninfo_t get_specsig_function(jl_codectx_t &ctx, Module *M, Value
7073
7069
param.addAttribute (Attribute::ReadOnly);
7074
7070
ty = PointerType::get (ty, AddressSpace::Derived);
7075
7071
}
7076
- else if (isboxed && jl_may_be_immutable_datatype (jt) && ! jl_is_abstracttype (jt)) {
7072
+ else if (isboxed && jl_is_immutable_datatype (jt)) {
7077
7073
param.addAttribute (Attribute::ReadOnly);
7078
7074
}
7079
7075
else if (jl_is_primitivetype (jt) && ty->isIntegerTy ()) {
0 commit comments