Skip to content

Commit 5cf41f5

Browse files
aviateskDrvi
authored andcommitted
release 1.10: backport the lattice fix for array op type checks (JuliaLang#52773) (JuliaLang#52774)
1 parent 5d98ff2 commit 5cf41f5

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

base/compiler/ssair/EscapeAnalysis/EscapeAnalysis.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,7 +1615,7 @@ function escape_builtin!(::typeof(arrayref), astate::AnalysisState, pc::Int, arg
16151615
argtypes = Any[argextype(args[i], astate.ir) for i in 2:length(args)]
16161616
boundcheckt = argtypes[1]
16171617
aryt = argtypes[2]
1618-
if !array_builtin_common_typecheck(boundcheckt, aryt, argtypes, 3)
1618+
if !array_builtin_common_typecheck(𝕃ₒ, boundcheckt, aryt, argtypes, 3)
16191619
add_thrown_escapes!(astate, pc, args, 2)
16201620
end
16211621
ary = args[3]
@@ -1679,7 +1679,7 @@ function escape_builtin!(::typeof(arrayset), astate::AnalysisState, pc::Int, arg
16791679
boundcheckt = argtypes[1]
16801680
aryt = argtypes[2]
16811681
valt = argtypes[3]
1682-
if !(array_builtin_common_typecheck(boundcheckt, aryt, argtypes, 4) &&
1682+
if !(array_builtin_common_typecheck(𝕃ₒ, boundcheckt, aryt, argtypes, 4) &&
16831683
arrayset_typecheck(aryt, valt))
16841684
add_thrown_escapes!(astate, pc, args, 2)
16851685
end

base/compiler/tfuncs.jl

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,12 +2034,12 @@ function array_type_undefable(@nospecialize(arytype))
20342034
end
20352035
end
20362036

2037-
function array_builtin_common_nothrow(argtypes::Vector{Any}, isarrayref::Bool)
2037+
function array_builtin_common_nothrow(𝕃::AbstractLattice, argtypes::Vector{Any}, isarrayref::Bool)
20382038
first_idx_idx = isarrayref ? 3 : 4
20392039
length(argtypes) first_idx_idx || return false
20402040
boundscheck = argtypes[1]
20412041
arytype = argtypes[2]
2042-
array_builtin_common_typecheck(boundscheck, arytype, argtypes, first_idx_idx) || return false
2042+
array_builtin_common_typecheck(𝕃, boundscheck, arytype, argtypes, first_idx_idx) || return false
20432043
if isarrayref
20442044
# If we could potentially throw undef ref errors, bail out now.
20452045
arytype = widenconst(arytype)
@@ -2056,8 +2056,9 @@ function array_builtin_common_nothrow(argtypes::Vector{Any}, isarrayref::Bool)
20562056
return false
20572057
end
20582058

2059-
@nospecs function array_builtin_common_typecheck(boundscheck, arytype,
2060-
argtypes::Vector{Any}, first_idx_idx::Int)
2059+
@nospecs function array_builtin_common_typecheck(𝕃::AbstractLattice,
2060+
boundscheck, arytype, argtypes::Vector{Any}, first_idx_idx::Int)
2061+
= Core.Compiler.:(𝕃)
20612062
(boundscheck Bool && arytype Array) || return false
20622063
for i = first_idx_idx:length(argtypes)
20632064
argtypes[i] Int || return false
@@ -2080,11 +2081,11 @@ end
20802081
@nospecs function _builtin_nothrow(𝕃::AbstractLattice, f, argtypes::Vector{Any}, rt)
20812082
= Core.Compiler.:(𝕃)
20822083
if f === arrayset
2083-
array_builtin_common_nothrow(argtypes, #=isarrayref=#false) || return false
2084+
array_builtin_common_nothrow(𝕃, argtypes, #=isarrayref=#false) || return false
20842085
# Additionally check element type compatibility
20852086
return arrayset_typecheck(argtypes[2], argtypes[3])
20862087
elseif f === arrayref || f === const_arrayref
2087-
return array_builtin_common_nothrow(argtypes, #=isarrayref=#true)
2088+
return array_builtin_common_nothrow(𝕃, argtypes, #=isarrayref=#true)
20882089
elseif f === Core._expr
20892090
length(argtypes) >= 1 || return false
20902091
return argtypes[1] Symbol

0 commit comments

Comments
 (0)