Skip to content

Commit f36db1b

Browse files
committed
wip
1 parent 850151e commit f36db1b

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

β€Žbase/compiler/abstractinterpretation.jlβ€Ž

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,13 @@ function const_prop_call(interp::AbstractInterpreter,
12491249
inf_cache = get_inference_cache(interp)
12501250
𝕃ᡒ = typeinf_lattice(interp)
12511251
argtypes = has_conditional(𝕃ᡒ, sv) ? ConditionalArgtypes(arginfo, sv) : SimpleArgtypes(arginfo.argtypes)
1252-
given_argtypes, overridden_by_const = matching_cache_argtypes(𝕃ᡒ, mi, argtypes, result.volatile_inf_result)
1252+
volatile_inf_result = result.volatile_inf_result
1253+
if volatile_inf_result !== nothing
1254+
cache_argtypes = volatile_inf_result.inf_result.argtypes
1255+
else
1256+
cache_argtypes = matching_cache_argtypes(𝕃ᡒ, mi)
1257+
end
1258+
given_argtypes = matching_cache_argtypes(𝕃ᡒ, mi, argtypes, cache_argtypes)
12531259
inf_result = cache_lookup(𝕃ᡒ, mi, given_argtypes, inf_cache)
12541260
if inf_result !== nothing
12551261
# found the cache for this constant prop'
@@ -1260,6 +1266,12 @@ function const_prop_call(interp::AbstractInterpreter,
12601266
@assert inf_result.linfo === mi "MethodInstance for cached inference result does not match"
12611267
return return_cached_result(interp, inf_result, sv)
12621268
end
1269+
overridden_by_const = falses(length(given_argtypes))
1270+
for i = 1:length(given_argtypes)
1271+
if given_argtypes[i] !== cache_argtypes[i]
1272+
overridden_by_const[i] = true
1273+
end
1274+
end
12631275
if !any(overridden_by_const)
12641276
add_remark!(interp, sv, "[constprop] Could not handle constant info in matching_cache_argtypes")
12651277
return nothing
@@ -1301,17 +1313,12 @@ as well as the other general extended lattice information.
13011313
"""
13021314
function matching_cache_argtypes(𝕃::AbstractLattice, mi::MethodInstance,
13031315
conditional_argtypes::ConditionalArgtypes,
1304-
volatile_inf_result::Union{Nothing,VolatileInferenceResult}=nothing)
1316+
cache_argtypes::Vector{Any})
13051317
(; arginfo, sv) = conditional_argtypes
13061318
(; fargs, argtypes) = arginfo
13071319
given_argtypes = Vector{Any}(undef, length(argtypes))
13081320
def = mi.def::Method
13091321
nargs = Int(def.nargs)
1310-
if volatile_inf_result !== nothing
1311-
cache_argtypes = volatile_inf_result.inf_result.argtypes
1312-
else
1313-
cache_argtypes = matching_cache_argtypes(𝕃, mi)
1314-
end
13151322
local condargs = nothing
13161323
for i in 1:length(argtypes)
13171324
argtype = argtypes[i]
@@ -1354,7 +1361,7 @@ function matching_cache_argtypes(𝕃::AbstractLattice, mi::MethodInstance,
13541361
else
13551362
given_argtypes = va_process_argtypes(𝕃, given_argtypes, mi)
13561363
end
1357-
return pick_const_args(𝕃, given_argtypes, cache_argtypes)
1364+
return pick_const_args!(𝕃, given_argtypes, cache_argtypes)
13581365
end
13591366

13601367
# This is only for use with `Conditional`.

β€Žbase/compiler/inferenceresult.jlβ€Ž

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,17 @@ usages and in general `matching_cache_argtypes(::MethodInstance, ::ConditionalAr
4040
is more preferred it can forward `Conditional` information.
4141
"""
4242
function matching_cache_argtypes(𝕃::AbstractLattice, mi::MethodInstance, simple_argtypes::SimpleArgtypes,
43-
volatile_inf_result::Union{Nothing,VolatileInferenceResult}=nothing)
43+
cache_argtypes::Vector{Any})
4444
(; argtypes) = simple_argtypes
4545
given_argtypes = Vector{Any}(undef, length(argtypes))
4646
for i = 1:length(argtypes)
4747
given_argtypes[i] = widenslotwrapper(argtypes[i])
4848
end
4949
given_argtypes = va_process_argtypes(𝕃, given_argtypes, mi)
50-
if volatile_inf_result !== nothing
51-
cache_argtypes = volatile_inf_result.inf_result.argtypes
52-
else
53-
cache_argtypes = matching_cache_argtypes(𝕃, mi)
54-
end
55-
return pick_const_args(𝕃, given_argtypes, cache_argtypes)
50+
return pick_const_args!(𝕃, given_argtypes, cache_argtypes)
5651
end
5752

58-
function pick_const_args(𝕃::AbstractLattice, given_argtypes::Vector{Any}, cache_argtypes::Vector{Any})
59-
overridden_by_const = falses(length(cache_argtypes))
60-
return pick_const_args!(𝕃, given_argtypes, cache_argtypes, overridden_by_const)
61-
end
62-
63-
function pick_const_args!(𝕃::AbstractLattice, given_argtypes::Vector{Any}, cache_argtypes::Vector{Any}, overridden_by_const::BitVector)
53+
function pick_const_args!(𝕃::AbstractLattice, given_argtypes::Vector{Any}, cache_argtypes::Vector{Any})
6454
nargtypes = length(given_argtypes)
6555
@assert nargtypes == length(cache_argtypes) #= == nargs =# "invalid `given_argtypes` for `mi`"
6656
for i = 1:nargtypes
@@ -74,12 +64,11 @@ function pick_const_args!(𝕃::AbstractLattice, given_argtypes::Vector{Any}, ca
7464
# declared method signature, narrow it down using `tmeet`
7565
given_argtypes[i] = tmeet(𝕃, given_argtype, cache_argtype)
7666
end
77-
overridden_by_const[i] = true
7867
else
7968
given_argtypes[i] = cache_argtype
8069
end
8170
end
82-
return given_argtypes, overridden_by_const
71+
return given_argtypes
8372
end
8473

8574
function is_argtype_match(𝕃::AbstractLattice,

0 commit comments

Comments
Β (0)