Skip to content

Commit 601c519

Browse files
committed
codegen: remove readonly from abstract type calling convention
Refs: #58070
1 parent 492d10a commit 601c519

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

Compiler/test/codegen.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,3 +1033,7 @@ end
10331033
const x57872 = "Hello"
10341034
f57872() = (Core.isdefinedglobal(@__MODULE__, Base.compilerbarrier(:const, :x57872)), x57872) # Extra globalref here to force world age bounds
10351035
@test f57872() == (true, "Hello")
1036+
1037+
@noinline f_mutateany(@nospecialize x) = x[] = 1
1038+
g_mutateany() = (y = Ref(0); f_mutateany(y); y[])
1039+
@test g_mutateany() === 1

src/codegen.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,7 +1600,7 @@ static MDNode *best_tbaa(jl_tbaacache_t &tbaa_cache, jl_value_t *jt) {
16001600
// note that this includes jl_isbits, although codegen should work regardless
16011601
static bool jl_is_concrete_immutable(jl_value_t* t)
16021602
{
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;
16041604
}
16051605

16061606
static bool jl_is_pointerfree(jl_value_t* t)
@@ -7385,8 +7385,8 @@ static Function *gen_cfun_wrapper(
73857385
inputarg = mark_julia_type(ctx, val, false, jargty);
73867386
}
73877387
}
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_concrete_immutable(jargty))) {
7389+
// must be a jl_value_t* (because it's mutable, abstract, or contains gc roots)
73907390
inputarg = mark_julia_type(ctx, maybe_decay_untracked(ctx, val), true, jargty_proper);
73917391
}
73927392
else {
@@ -7980,7 +7980,7 @@ static jl_returninfo_t get_specsig_function(jl_codegen_params_t &params, Module
79807980
param.addAttribute(Attribute::ReadOnly);
79817981
ty = PointerType::get(M->getContext(), AddressSpace::Derived);
79827982
}
7983-
else if (isboxed && jl_is_immutable_datatype(jt)) {
7983+
else if (isboxed && jl_may_be_immutable_datatype(jt) && !jl_is_abstracttype(jt)) {
79847984
param.addAttribute(Attribute::ReadOnly);
79857985
}
79867986
else if (jl_is_primitivetype(jt) && ty->isIntegerTy()) {

src/julia.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1617,7 +1617,7 @@ static inline int jl_field_isconst(jl_datatype_t *st, int i) JL_NOTSAFEPOINT
16171617
#define jl_is_mutable(t) (((jl_datatype_t*)t)->name->mutabl)
16181618
#define jl_is_mutable_datatype(t) (jl_is_datatype(t) && (((jl_datatype_t*)t)->name->mutabl))
16191619
#define jl_is_immutable(t) (!((jl_datatype_t*)t)->name->mutabl)
1620-
#define jl_is_immutable_datatype(t) (jl_is_datatype(t) && (!((jl_datatype_t*)t)->name->mutabl))
1620+
#define jl_may_be_immutable_datatype(t) (jl_is_datatype(t) && (!((jl_datatype_t*)t)->name->mutabl))
16211621
#define jl_is_uniontype(v) jl_typetagis(v,jl_uniontype_tag<<4)
16221622
#define jl_is_typevar(v) jl_typetagis(v,jl_tvar_tag<<4)
16231623
#define jl_is_unionall(v) jl_typetagis(v,jl_unionall_tag<<4)

0 commit comments

Comments
 (0)