@@ -136,7 +136,7 @@ static DIType *_julia_type_to_di(jl_codegen_params_t *ctx, jl_value_t *jt, DIBui
136
136
size_t ntypes = jl_datatype_nfields (jdt);
137
137
std::vector<llvm::Metadata*> Elements (ntypes);
138
138
for (unsigned i = 0 ; i < ntypes; i++) {
139
- jl_value_t *el = jl_svecref (jdt-> types , i);
139
+ jl_value_t *el = jl_field_type_concrete (jdt, i);
140
140
DIType *di;
141
141
if (jl_field_isptr (jdt, i))
142
142
di = jl_pvalue_dillvmt;
@@ -2039,9 +2039,10 @@ static bool emit_getfield_unknownidx(jl_codectx_t &ctx,
2039
2039
if (!strct.ispointer ()) { // unboxed
2040
2040
assert (jl_is_concrete_immutable ((jl_value_t *)stt));
2041
2041
bool isboxed = is_datatype_all_pointers (stt);
2042
- bool issame = is_tupletype_homogeneous (stt->types );
2042
+ jl_svec_t *types = stt->types ;
2043
+ bool issame = is_tupletype_homogeneous (types);
2043
2044
if (issame) {
2044
- jl_value_t *jft = jl_svecref (stt-> types , 0 );
2045
+ jl_value_t *jft = jl_svecref (types, 0 );
2045
2046
if (strct.isghost ) {
2046
2047
(void )idx0 ();
2047
2048
*ret = ghostValue (jft);
@@ -2081,7 +2082,7 @@ static bool emit_getfield_unknownidx(jl_codectx_t &ctx,
2081
2082
ctx.builder .CreateExtractValue (strct.V , makeArrayRef (i)),
2082
2083
fld);
2083
2084
}
2084
- jl_value_t *jft = issame ? jl_svecref (stt-> types , 0 ) : (jl_value_t *)jl_any_type;
2085
+ jl_value_t *jft = issame ? jl_svecref (types, 0 ) : (jl_value_t *)jl_any_type;
2085
2086
if (isboxed && maybe_null)
2086
2087
null_pointer_check (ctx, fld);
2087
2088
*ret = mark_julia_type (ctx, fld, isboxed, jft);
@@ -2123,9 +2124,9 @@ static bool emit_getfield_unknownidx(jl_codectx_t &ctx,
2123
2124
*ret = mark_julia_type (ctx, fld, true , jl_any_type);
2124
2125
return true ;
2125
2126
}
2126
- else if (is_tupletype_homogeneous (stt-> types )) {
2127
+ else if (is_tupletype_homogeneous (jl_get_fieldtypes ( stt) )) {
2127
2128
assert (nfields > 0 ); // nf == 0 trapped by all_pointers case
2128
- jl_value_t *jft = jl_svecref (stt->types , 0 );
2129
+ jl_value_t *jft = jl_svecref (stt->types , 0 ); // n.b. jl_get_fieldtypes assigned stt->types for here
2129
2130
assert (jl_is_concrete_type (jft));
2130
2131
idx = idx0 ();
2131
2132
Value *ptr = maybe_decay_tracked (ctx, data_pointer (ctx, strct));
@@ -3255,9 +3256,10 @@ static void find_perm_offsets(jl_datatype_t *typ, SmallVector<unsigned,4> &res,
3255
3256
// This is a inlined field at `offset`.
3256
3257
if (!typ->layout || typ->layout ->npointers == 0 )
3257
3258
return ;
3258
- size_t nf = jl_svec_len (typ->types );
3259
+ jl_svec_t *types = jl_get_fieldtypes (typ);
3260
+ size_t nf = jl_svec_len (types);
3259
3261
for (size_t i = 0 ; i < nf; i++) {
3260
- jl_value_t *_fld = jl_svecref (typ-> types , i);
3262
+ jl_value_t *_fld = jl_svecref (types, i);
3261
3263
if (!jl_is_datatype (_fld))
3262
3264
continue ;
3263
3265
jl_datatype_t *fld = (jl_datatype_t *)_fld;
@@ -3291,7 +3293,7 @@ static jl_cgval_t emit_setfield(jl_codectx_t &ctx,
3291
3293
const jl_cgval_t *modifyop, const std::string &fname)
3292
3294
{
3293
3295
if (!sty->name ->mutabl && checked) {
3294
- std::string msg = fname + " immutable struct of type "
3296
+ std::string msg = fname + " : immutable struct of type "
3295
3297
+ std::string (jl_symbol_name (sty->name ->name ))
3296
3298
+ " cannot be changed" ;
3297
3299
emit_error (ctx, msg);
@@ -3306,7 +3308,7 @@ static jl_cgval_t emit_setfield(jl_codectx_t &ctx,
3306
3308
emit_bitcast (ctx, maybe_decay_tracked (ctx, addr), T_pint8),
3307
3309
ConstantInt::get (T_size, byte_offset)); // TODO: use emit_struct_gep
3308
3310
}
3309
- jl_value_t *jfty = jl_svecref (sty-> types , idx0);
3311
+ jl_value_t *jfty = jl_field_type (sty, idx0);
3310
3312
if (!jl_field_isptr (sty, idx0) && jl_is_uniontype (jfty)) {
3311
3313
size_t fsz = 0 , al = 0 ;
3312
3314
bool isptr = !jl_islayout_inline (jfty, &fsz, &al);
@@ -3431,7 +3433,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
3431
3433
}
3432
3434
3433
3435
for (unsigned i = 0 ; i < na; i++) {
3434
- jl_value_t *jtype = jl_svecref (sty->types , i);
3436
+ jl_value_t *jtype = jl_svecref (sty->types , i); // n.b. ty argument must be concrete
3435
3437
jl_cgval_t fval_info = argv[i];
3436
3438
emit_typecheck (ctx, fval_info, jtype, " new" );
3437
3439
fval_info = update_julia_type (ctx, fval_info, jtype);
@@ -3566,7 +3568,7 @@ static jl_cgval_t emit_new_struct(jl_codectx_t &ctx, jl_value_t *ty, size_t narg
3566
3568
need_wb = !rhs.isboxed ;
3567
3569
else
3568
3570
need_wb = false ;
3569
- emit_typecheck (ctx, rhs, jl_svecref (sty->types , i), " new" );
3571
+ emit_typecheck (ctx, rhs, jl_svecref (sty->types , i), " new" ); // n.b. ty argument must be concrete
3570
3572
emit_setfield (ctx, sty, strctinfo, i, rhs, jl_cgval_t (), false , need_wb, AtomicOrdering::NotAtomic, AtomicOrdering::NotAtomic, false , true , false , false , false , nullptr , " " );
3571
3573
}
3572
3574
return strctinfo;
0 commit comments