From 631e7ef6ffee377b87b4a156cc41bb25305a6c31 Mon Sep 17 00:00:00 2001 From: N5N3 <2642243996@qq.com> Date: Thu, 21 Dec 2023 18:00:25 +0800 Subject: [PATCH] effect: mark `Core.TypeofVararg` as `ismutationfree` (#52586) Found in https://buildkite.com/julialang/julia-master/builds/31309#018c7f0b-aada-4017-bb2f-44001593ac6b. On master keyword call might taint `inaccessiblememonly`. MWE: ```julia julia> foo(; kws...) = 1 foo (generic function with 1 method) julia> Base.infer_effects(foo, Tuple{}) (+c,+e,+n,+t,+s,!m,+u) ``` which is caused by ```julia julia> Base.infer_effects(()->Vararg) (+c,+e,+n,+t,+s,!m,+u) ``` Co-authored-by: Shuhei Kadowaki <40514306+aviatesk@users.noreply.github.com> --- src/jltypes.c | 1 + test/compiler/effects.jl | 3 +++ 2 files changed, 4 insertions(+) diff --git a/src/jltypes.c b/src/jltypes.c index f0f3b36951a2b..5bd5ec31185d9 100644 --- a/src/jltypes.c +++ b/src/jltypes.c @@ -2785,6 +2785,7 @@ void jl_init_types(void) JL_GC_DISABLED XX(vararg); // It seems like we probably usually end up needing the box for kinds (often used in an Any context), so force it to exist jl_vararg_type->name->mayinlinealloc = 0; + jl_vararg_type->ismutationfree = 1; jl_svec_t *anytuple_params = jl_svec(1, jl_wrap_vararg((jl_value_t*)jl_any_type, (jl_value_t*)NULL, 0)); jl_anytuple_type = jl_new_datatype(jl_symbol("Tuple"), core, jl_any_type, anytuple_params, diff --git a/test/compiler/effects.jl b/test/compiler/effects.jl index f9593ab35bab6..0c95ca0a29aab 100644 --- a/test/compiler/effects.jl +++ b/test/compiler/effects.jl @@ -1357,6 +1357,9 @@ end @test set_a52531!(1) == 1 @test get_a52531() == 1 +@test Core.Compiler.is_inaccessiblememonly(Base.infer_effects(identity∘identity, Tuple{Any})) +@test Core.Compiler.is_inaccessiblememonly(Base.infer_effects(()->Vararg, Tuple{})) + # pointerref nothrow for invalid pointer @test !Core.Compiler.intrinsic_nothrow(Core.Intrinsics.pointerref, Any[Type{Ptr{Vector{Int64}}}, Int, Int]) @test !Core.Compiler.intrinsic_nothrow(Core.Intrinsics.pointerref, Any[Type{Ptr{T}} where T, Int, Int])