compute mayinlinealloc more accurately (for ccall)#40947
Conversation
This allows code to assume that `->layout` will be assigned when analyzing a type in codegen if the type is mapped to C. The ABI code often assumes this, and it is also just much generally easier that the jl_struct_to_llvm code can share the jl_compute_field_offsets results.
fc9d6ed to
802658d
Compare
| if (ty->layout->npointers > 0) { | ||
| if (pointerfree) | ||
| return 0; | ||
| if (ty->ninitialized != jl_svec_len(ty->types)) |
There was a problem hiding this comment.
No need to do it now, but it occurs to me ninitialized can move to TypeName as well?
There was a problem hiding this comment.
Good observation. I can make it n_uninitialized, then it would be shared. I'll do that once this is merged. I've also thought about removing ->names, since that is always shared too.
There was a problem hiding this comment.
names isn't shared for NamedTuples. I guess if we wanted we could fetch it out of the parameters in that case though.
| jl_datatype_t *jst = (jl_datatype_t*)ty; | ||
| return jst->layout || jl_has_fixed_layout(jst); | ||
| } | ||
| if (jl_is_tuple_type(jl_unwrap_unionall(ty))) |
There was a problem hiding this comment.
Why are tuple types a special case here?
There was a problem hiding this comment.
It would need to forward a covariant flag through jl_has_fixed_layout, and it just seemed unnecessary initially. People probably aren't trying to pass in abstract Tuples by value to ccall very often.
This allows code to assume that `->layout` will be assigned when analyzing a type in codegen if the type is mapped to C. The ABI code often assumes this, and it is also just much generally easier that the jl_struct_to_llvm code can share the jl_compute_field_offsets results.
This allows code to assume that `->layout` will be assigned when analyzing a type in codegen if the type is mapped to C. The ABI code often assumes this, and it is also just much generally easier that the jl_struct_to_llvm code can share the jl_compute_field_offsets results.
This allows code to assume that
->layoutwill be assigned whenanalyzing a type in codegen if the type is mapped to C. The ABI code
often assumes this, and it is also just much generally easier that the
jl_struct_to_llvm code can share the jl_compute_field_offsets results.