Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inference: use ssa_def_slot for typeassert refinement #56859

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Compiler/src/abstractinterpretation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2656,7 +2656,7 @@ function abstract_call_known(interp::AbstractInterpreter, @nospecialize(f),
if sv isa InferenceState && f === typeassert
# perform very limited back-propagation of invariants after this type assertion
if rt !== Bottom && isa(fargs, Vector{Any})
farg2 = fargs[2]
farg2 = ssa_def_slot(fargs[2], sv)
if farg2 isa SlotNumber
refinements = SlotRefinement(farg2, rt)
end
Expand Down
11 changes: 11 additions & 0 deletions Compiler/test/inference.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4103,6 +4103,17 @@ end == [Union{Some{Float64}, Some{Int}, Some{UInt8}}]
end
return a
end == Union{Int32,Int64}

@test Base.infer_return_type((Vector{Any},)) do args
codeinst = first(args)
if codeinst isa Core.MethodInstance
mi = codeinst
else
codeinst::Core.CodeInstance
mi = codeinst.def
end
return mi
end == Core.MethodInstance
end

callsig_backprop_basic(::Int) = nothing
Expand Down
Loading