diff --git a/base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl b/base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl index 2469507fd3699..a7778f0ef1381 100644 --- a/base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl +++ b/base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl @@ -1615,7 +1615,7 @@ function escape_builtin!(::typeof(arrayref), astate::AnalysisState, pc::Int, arg argtypes = Any[argextype(args[i], astate.ir) for i in 2:length(args)] boundcheckt = argtypes[1] aryt = argtypes[2] - if !array_builtin_common_typecheck(boundcheckt, aryt, argtypes, 3) + if !array_builtin_common_typecheck(𝕃ₒ, boundcheckt, aryt, argtypes, 3) add_thrown_escapes!(astate, pc, args, 2) end ary = args[3] @@ -1679,7 +1679,7 @@ function escape_builtin!(::typeof(arrayset), astate::AnalysisState, pc::Int, arg boundcheckt = argtypes[1] aryt = argtypes[2] valt = argtypes[3] - if !(array_builtin_common_typecheck(boundcheckt, aryt, argtypes, 4) && + if !(array_builtin_common_typecheck(𝕃ₒ, boundcheckt, aryt, argtypes, 4) && arrayset_typecheck(aryt, valt)) add_thrown_escapes!(astate, pc, args, 2) end diff --git a/base/compiler/tfuncs.jl b/base/compiler/tfuncs.jl index 9dfda5f1e4eea..708db9c98d814 100644 --- a/base/compiler/tfuncs.jl +++ b/base/compiler/tfuncs.jl @@ -2034,12 +2034,12 @@ function array_type_undefable(@nospecialize(arytype)) end end -function array_builtin_common_nothrow(argtypes::Vector{Any}, isarrayref::Bool) +function array_builtin_common_nothrow(𝕃::AbstractLattice, argtypes::Vector{Any}, isarrayref::Bool) first_idx_idx = isarrayref ? 3 : 4 length(argtypes) ≥ first_idx_idx || return false boundscheck = argtypes[1] arytype = argtypes[2] - array_builtin_common_typecheck(boundscheck, arytype, argtypes, first_idx_idx) || return false + array_builtin_common_typecheck(𝕃, boundscheck, arytype, argtypes, first_idx_idx) || return false if isarrayref # If we could potentially throw undef ref errors, bail out now. arytype = widenconst(arytype) @@ -2056,8 +2056,9 @@ function array_builtin_common_nothrow(argtypes::Vector{Any}, isarrayref::Bool) return false end -@nospecs function array_builtin_common_typecheck(boundscheck, arytype, - argtypes::Vector{Any}, first_idx_idx::Int) +@nospecs function array_builtin_common_typecheck(𝕃::AbstractLattice, + boundscheck, arytype, argtypes::Vector{Any}, first_idx_idx::Int) + ⊑ = Core.Compiler.:⊑(𝕃) (boundscheck ⊑ Bool && arytype ⊑ Array) || return false for i = first_idx_idx:length(argtypes) argtypes[i] ⊑ Int || return false @@ -2080,11 +2081,11 @@ end @nospecs function _builtin_nothrow(𝕃::AbstractLattice, f, argtypes::Vector{Any}, rt) ⊑ = Core.Compiler.:⊑(𝕃) if f === arrayset - array_builtin_common_nothrow(argtypes, #=isarrayref=#false) || return false + array_builtin_common_nothrow(𝕃, argtypes, #=isarrayref=#false) || return false # Additionally check element type compatibility return arrayset_typecheck(argtypes[2], argtypes[3]) elseif f === arrayref || f === const_arrayref - return array_builtin_common_nothrow(argtypes, #=isarrayref=#true) + return array_builtin_common_nothrow(𝕃, argtypes, #=isarrayref=#true) elseif f === Core._expr length(argtypes) >= 1 || return false return argtypes[1] ⊑ Symbol