@@ -44,7 +44,7 @@ function should_infer_this_call(interp::AbstractInterpreter, sv::InferenceState)
44
44
end
45
45
46
46
function should_infer_for_effects (sv:: InferenceState )
47
- effects = Effects (sv)
47
+ effects = sv . ipo_effects
48
48
return is_terminates (effects) && is_effect_free (effects)
49
49
end
50
50
@@ -255,7 +255,7 @@ struct MethodMatches
255
255
applicable:: Vector{Any}
256
256
info:: MethodMatchInfo
257
257
valid_worlds:: WorldRange
258
- mt:: Core. MethodTable
258
+ mt:: MethodTable
259
259
fullmatch:: Bool
260
260
nonoverlayed:: Bool
261
261
end
@@ -267,7 +267,7 @@ struct UnionSplitMethodMatches
267
267
applicable_argtypes:: Vector{Vector{Any}}
268
268
info:: UnionSplitInfo
269
269
valid_worlds:: WorldRange
270
- mts:: Vector{Core. MethodTable}
270
+ mts:: Vector{MethodTable}
271
271
fullmatches:: Vector{Bool}
272
272
nonoverlayed:: Bool
273
273
end
@@ -282,15 +282,15 @@ function find_matching_methods(argtypes::Vector{Any}, @nospecialize(atype), meth
282
282
applicable = Any[]
283
283
applicable_argtypes = Vector{Any}[] # arrays like `argtypes`, including constants, for each match
284
284
valid_worlds = WorldRange ()
285
- mts = Core . MethodTable[]
285
+ mts = MethodTable[]
286
286
fullmatches = Bool[]
287
287
nonoverlayed = true
288
288
for i in 1 : length (split_argtypes)
289
289
arg_n = split_argtypes[i]:: Vector{Any}
290
290
sig_n = argtypes_to_type (arg_n)
291
291
mt = ccall (:jl_method_table_for , Any, (Any,), sig_n)
292
292
mt === nothing && return FailedMethodMatch (" Could not identify method table for call" )
293
- mt = mt:: Core. MethodTable
293
+ mt = mt:: MethodTable
294
294
result = findall (sig_n, method_table; limit = max_methods)
295
295
if result === nothing
296
296
return FailedMethodMatch (" For one of the union split cases, too many methods matched" )
@@ -329,7 +329,7 @@ function find_matching_methods(argtypes::Vector{Any}, @nospecialize(atype), meth
329
329
if mt === nothing
330
330
return FailedMethodMatch (" Could not identify method table for call" )
331
331
end
332
- mt = mt:: Core. MethodTable
332
+ mt = mt:: MethodTable
333
333
result = findall (atype, method_table; limit = max_methods)
334
334
if result === nothing
335
335
# this means too many methods matched
@@ -502,22 +502,24 @@ function conditional_argtype(@nospecialize(rt), @nospecialize(sig), argtypes::Ve
502
502
end
503
503
end
504
504
505
- function add_call_backedges! (interp:: AbstractInterpreter ,
506
- @nospecialize (rettype), all_effects:: Effects ,
505
+ function add_call_backedges! (interp:: AbstractInterpreter , @nospecialize (rettype), all_effects:: Effects ,
507
506
edges:: Vector{MethodInstance} , matches:: Union{MethodMatches,UnionSplitMethodMatches} , @nospecialize (atype),
508
507
sv:: InferenceState )
509
- # we don't need to add backedges when:
510
- # - a new method couldn't refine (widen) this type and
511
- # - the effects are known to not provide any useful IPO information
508
+ # don't bother to add backedges when both type and effects information are already
509
+ # maximized to the top since a new method couldn't refine or widen them anyway
512
510
if rettype === Any
511
+ # ignore the `:nonoverlayed` property if `interp` doesn't use overlayed method table
512
+ # since it will never be tainted anyway
513
513
if ! isoverlayed (method_table (interp))
514
- # we can ignore the `nonoverlayed` property if `interp` doesn't use
515
- # overlayed method table at all since it will never be tainted anyway
516
514
all_effects = Effects (all_effects; nonoverlayed= false )
517
515
end
518
- if all_effects === Effects ()
519
- return
516
+ if (# ignore the `:noinbounds` property if `:consistent`-cy is tainted already
517
+ sv. ipo_effects. consistent === ALWAYS_FALSE || all_effects. consistent === ALWAYS_FALSE ||
518
+ # or this `:noinbounds` doesn't taint it
519
+ ! stmt_taints_inbounds_consistency (sv))
520
+ all_effects = Effects (all_effects; noinbounds= false )
520
521
end
522
+ all_effects === Effects () && return nothing
521
523
end
522
524
for edge in edges
523
525
add_backedge! (sv, edge)
@@ -531,6 +533,7 @@ function add_call_backedges!(interp::AbstractInterpreter,
531
533
thisfullmatch || add_mt_backedge! (sv, mt, atype)
532
534
end
533
535
end
536
+ return nothing
534
537
end
535
538
536
539
const RECURSION_UNUSED_MSG = " Bounded recursion detected with unused result. Annotated return type may be wider than true result."
@@ -688,7 +691,7 @@ function edge_matches_sv(frame::InferenceState, method::Method, @nospecialize(si
688
691
if callee_method2 != = inf_method2
689
692
return false
690
693
end
691
- if ! hardlimit
694
+ if ! hardlimit || InferenceParams (sv . interp) . ignore_recursion_hardlimit
692
695
# if this is a soft limit,
693
696
# also inspect the parent of this edge,
694
697
# to see if they are the same Method as sv
@@ -1018,9 +1021,9 @@ function abstract_call_method_with_const_args(interp::AbstractInterpreter,
1018
1021
add_remark! (interp, sv, " [constprop] Fresh constant inference hit a cycle" )
1019
1022
return nothing
1020
1023
end
1021
- @assert ! isa ( inf_result. result, InferenceState)
1024
+ @assert inf_result. result != = nothing
1022
1025
else
1023
- if isa ( inf_result. result, InferenceState)
1026
+ if inf_result. result === nothing
1024
1027
add_remark! (interp, sv, " [constprop] Found cached constant inference in a cycle" )
1025
1028
return nothing
1026
1029
end
@@ -2475,7 +2478,8 @@ function abstract_eval_foreigncall(interp::AbstractInterpreter, e::Expr, vtypes:
2475
2478
override. terminates_globally ? true : effects. terminates,
2476
2479
override. notaskstate ? true : effects. notaskstate,
2477
2480
override. inaccessiblememonly ? ALWAYS_TRUE : effects. inaccessiblememonly,
2478
- effects. nonoverlayed)
2481
+ effects. nonoverlayed,
2482
+ effects. noinbounds)
2479
2483
end
2480
2484
return RTEffects (t, effects)
2481
2485
end
@@ -2820,7 +2824,7 @@ end
2820
2824
2821
2825
# make as much progress on `frame` as possible (without handling cycles)
2822
2826
function typeinf_local (interp:: AbstractInterpreter , frame:: InferenceState )
2823
- @assert ! frame. inferred
2827
+ @assert ! is_inferred ( frame)
2824
2828
frame. dont_work_on_me = true # mark that this function is currently on the stack
2825
2829
W = frame. ip
2826
2830
nargs = narguments (frame, #= include_va=# false )
@@ -3081,7 +3085,7 @@ function typeinf_nocycle(interp::AbstractInterpreter, frame::InferenceState)
3081
3085
typeinf_local (interp, caller)
3082
3086
no_active_ips_in_callers = false
3083
3087
end
3084
- caller . valid_worlds = intersect (caller. valid_worlds , frame. valid_worlds)
3088
+ update_valid_age! (caller, frame. valid_worlds)
3085
3089
end
3086
3090
end
3087
3091
return true
0 commit comments