Skip to content

Commit c39510e

Browse files
vtjnashKristofferC
authored andcommitted
optimizer: bail out of inlining if ir_inline_unionsplit will fail (#44416)
Intersection cannot deal with this `metharg`, so it does not simplify the type at all when handling this case. This can cause us to run into an assertion later, where we assume the intersection of a non-Varags type will always return a simple DataType without Varargs. Fixes #44238 atype = Tuple{typeof(Base.similar), Tuple{Union{Polyhedra.Polyhedron{T}, Polyhedra.Representation{T}} where T}, Array{_A, 1} where _A, Array{_C, 1} where _C, Array{_B, 1} where _B} metharg = Tuple{typeof(Base.similar), Tuple{Vararg{Union{Polyhedra.Polyhedron{T}, Polyhedra.Representation{T}} where T}}, Vararg{Union{Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.HyperPlane{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.HalfSpace{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:AbstractArray{T, 1}, Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.Line{T, AT} where AT<:AbstractArray{T, 1}), Union{AbstractArray{var"#s14", 1}, Polyhedra.AbstractRepIterator{var"#s13", var"#s14"} where var"#s13", Polyhedra.AllRepIterator{var"#s14", var"#s14", LinElemT, LRT, RT} where RT<:Polyhedra.AbstractRepIterator{var"#s14", var"#s14"} where LRT<:Polyhedra.AbstractRepIterator{var"#s14", LinElemT} where LinElemT where var"#s14"} where var"#s14"<:(Polyhedra.Ray{T, AT} where AT<:AbstractArray{T, 1})} where T}} Currently `typeintersection(atype, metharg) === metharg` (cherry picked from commit ffc5ffa)
1 parent f2539a0 commit c39510e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

base/compiler/ssair/inlining.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,9 @@ end
820820
function analyze_method!(match::MethodMatch, argtypes::Vector{Any},
821821
flag::UInt8, state::InliningState)
822822
method = match.method
823-
methsig = method.sig
823+
spec_types = match.spec_types
824824

825-
# Check that we habe the correct number of arguments
825+
# Check that we have the correct number of arguments
826826
na = Int(method.nargs)
827827
npassedargs = length(argtypes)
828828
if na != npassedargs && !(na > 0 && method.isva)
@@ -832,6 +832,13 @@ function analyze_method!(match::MethodMatch, argtypes::Vector{Any},
832832
# call this function
833833
return nothing
834834
end
835+
if !match.fully_covers
836+
# type-intersection was not able to give us a simple list of types, so
837+
# ir_inline_unionsplit won't be able to deal with inlining this
838+
if !(spec_types isa DataType && length(spec_types.parameters) == length(argtypes) && !isvarargtype(spec_types.parameters[end]))
839+
return nothing
840+
end
841+
end
835842

836843
# Bail out if any static parameters are left as TypeVar
837844
validate_sparams(match.sparams) || return nothing

0 commit comments

Comments
 (0)