From b8c347aca8daf0826861450e8d857e01a9aeba01 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Fri, 5 May 2023 13:50:43 -0400 Subject: [PATCH] Thread lattice through tuple_tail_elem (#49643) --- base/compiler/abstractinterpretation.jl | 4 ++-- base/compiler/typelimits.jl | 2 +- base/compiler/typeutils.jl | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/base/compiler/abstractinterpretation.jl b/base/compiler/abstractinterpretation.jl index 6e671b032dbeb..0e5a99eedf2ee 100644 --- a/base/compiler/abstractinterpretation.jl +++ b/base/compiler/abstractinterpretation.jl @@ -1539,7 +1539,7 @@ function abstract_apply(interp::AbstractInterpreter, argtypes::Vector{Any}, si:: # This is vararg, we're not gonna be able to do any inlining, # drop the info info = nothing - tail = tuple_tail_elem(unwrapva(ct[end]), cti) + tail = tuple_tail_elem(typeinf_lattice(interp), unwrapva(ct[end]), cti) push!(ctypes´, push!(ct[1:(end - 1)], tail)) else push!(ctypes´, append!(ct[:], cti)) @@ -1562,7 +1562,7 @@ function abstract_apply(interp::AbstractInterpreter, argtypes::Vector{Any}, si:: for i = 1:lct-1 cti = ct[i] if isvarargtype(cti) - ct[i] = tuple_tail_elem(unwrapva(cti), ct[(i+1):lct]) + ct[i] = tuple_tail_elem(typeinf_lattice(interp), unwrapva(cti), ct[(i+1):lct]) resize!(ct, i) break end diff --git a/base/compiler/typelimits.jl b/base/compiler/typelimits.jl index 8e845d6f21888..191820951fae1 100644 --- a/base/compiler/typelimits.jl +++ b/base/compiler/typelimits.jl @@ -138,7 +138,7 @@ function _limit_type_size(@nospecialize(t), @nospecialize(c), sources::SimpleVec Q = Any[ tP[i] for i in 1:np ] if ltP > np # combine tp[np:end] into tP[np] using Vararg - Q[np] = tuple_tail_elem(Bottom, Any[ tP[i] for i in np:ltP ]) + Q[np] = tuple_tail_elem(fallback_lattice, Bottom, Any[ tP[i] for i in np:ltP ]) end for i = 1:np # now apply limit element-wise to Q diff --git a/base/compiler/typeutils.jl b/base/compiler/typeutils.jl index 98117fd7cb345..cff10b02ceafc 100644 --- a/base/compiler/typeutils.jl +++ b/base/compiler/typeutils.jl @@ -213,11 +213,11 @@ end _typename(union::UnionAll) = _typename(union.body) _typename(a::DataType) = Const(a.name) -function tuple_tail_elem(@nospecialize(init), ct::Vector{Any}) +function tuple_tail_elem(𝕃::AbstractLattice, @nospecialize(init), ct::Vector{Any}) t = init for x in ct # FIXME: this is broken: it violates subtyping relations and creates invalid types with free typevars - t = tmerge(t, unwraptv(unwrapva(x))) + t = tmerge(𝕃, t, unwraptv(unwrapva(x))) end return Vararg{widenconst(t)} end