Skip to content

Commit 4674928

Browse files
committed
inference: refactoring to allow irinterp to perform :call inference
This commit implements a significant refactoring of the inference routines, which is necessary to enable `:call` inference in irinterp. While this commit does not yet enable `:call` inference, a subsequent small commit will do so. This is because external `AbstractInterpreter`s first need to adjust their code for this refactoring, and in the event of a regression detected by the recursive `:call` inference, we will be able to simply revert the small commit. Additionally, this commit improves the robustness of irinterp by allowing it to handle invoke calls, which currently result in a crash. TODOs: - [x] implement a simple recursion detection mechanism for `IRInterpretationState` - [x] add proper invalidation support - [x] allow constant inference from semi-concrete interpretation - [x] propagate callinfo and allow double inlining
1 parent 2092000 commit 4674928

File tree

12 files changed

+799
-577
lines changed

12 files changed

+799
-577
lines changed

base/compiler/abstractinterpretation.jl

Lines changed: 207 additions & 180 deletions
Large diffs are not rendered by default.

base/compiler/compiler.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ include("compiler/ssair/domtree.jl")
152152
include("compiler/ssair/ir.jl")
153153

154154
include("compiler/abstractlattice.jl")
155-
156155
include("compiler/inferenceresult.jl")
157156
include("compiler/inferencestate.jl")
158157

base/compiler/inferenceresult.jl

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function va_process_argtypes(@nospecialize(va_handler!), 𝕃::AbstractLattice,
8686
nargs = Int(def.nargs)
8787
if isva || isvarargtype(given_argtypes[end])
8888
isva_given_argtypes = Vector{Any}(undef, nargs)
89-
for i = 1:(nargs - isva)
89+
for i = 1:(nargs-isva)
9090
isva_given_argtypes[i] = argtype_by_index(given_argtypes, i)
9191
end
9292
if isva
@@ -110,10 +110,8 @@ function most_general_argtypes(method::Union{Method, Nothing}, @nospecialize(spe
110110
isva = !toplevel && method.isva
111111
linfo_argtypes = Any[(unwrap_unionall(specTypes)::DataType).parameters...]
112112
nargs::Int = toplevel ? 0 : method.nargs
113-
if !withfirst
114-
# For opaque closure, the closure environment is processed elsewhere
115-
nargs -= 1
116-
end
113+
# For opaque closure, the closure environment is processed elsewhere
114+
withfirst || (nargs -= 1)
117115
cache_argtypes = Vector{Any}(undef, nargs)
118116
# First, if we're dealing with a varargs method, then we set the last element of `args`
119117
# to the appropriate `Tuple` type or `PartialStruct` instance.

0 commit comments

Comments
 (0)