@@ -7,7 +7,7 @@ using .CC: AbstractInterpreter, NativeInterpreter, InferenceParams, Optimization
77 StmtInfo, MethodCallResult, ConstCallResults, ConstPropResult, MethodTableView,
88 CachedMethodTable, InternalMethodTable, OverlayMethodTable, CallMeta, CallInfo,
99 IRCode, LazyDomtree, IRInterpretationState, set_inlineable!, block_for_inst,
10- BitSetBoundedMinPrioritySet, AbsIntState
10+ BitSetBoundedMinPrioritySet, AbsIntState, Future
1111using Base: IdSet
1212using StateSelection: DiffGraph
1313
@@ -282,13 +282,13 @@ widenincidence(@nospecialize(x)) = x
282282 if length (argtypes) == 2
283283 xarg = argtypes[2 ]
284284 if isa (xarg, Union{Incidence, Const})
285- return structural_inc_ddt (interp. var_to_diff, interp. var_kind, xarg)
285+ return Future {CallMeta} ( structural_inc_ddt (interp. var_to_diff, interp. var_kind, xarg) )
286286 end
287287 end
288288 end
289289 if interp. in_analysis && ! isa (f, Core. Builtin) && ! isa (f, Core. IntrinsicFunction)
290290 # We don't want to do new inference here
291- return CallMeta ( Any, Any, CC. Effects (), CC. NoCallInfo ())
291+ return Future { CallMeta} ( CallMeta ( Any, Any, CC. Effects (), CC. NoCallInfo () ))
292292 end
293293 ret = @invoke CC. abstract_call_known (interp:: AbstractInterpreter , f:: Any ,
294294 arginfo:: ArgInfo , si:: StmtInfo , sv:: AbsIntState , max_methods:: Int )
@@ -305,27 +305,27 @@ widenincidence(@nospecialize(x)) = x
305305 end
306306 end
307307 arginfo = ArgInfo (arginfo. fargs, map (widenincidence, arginfo. argtypes))
308- r = Diffractor. fwd_abstract_call_gf_by_type (interp, f, arginfo, si, sv, ret)
309- r != = nothing && return r
310- return ret
308+ return Diffractor. fwd_abstract_call_gf_by_type (interp, f, arginfo, si, sv, ret)
311309end
312310
313311@override function CC. abstract_call_method (interp:: DAEInterpreter ,
314312 method:: Method , @nospecialize (sig), sparams:: SimpleVector , hardlimit:: Bool , si:: StmtInfo , sv:: InferenceState )
315- ret = @invoke CC. abstract_call_method (interp:: AbstractInterpreter ,
313+ mret = @invoke CC. abstract_call_method (interp:: AbstractInterpreter ,
316314 method:: Method , sig:: Any , sparams:: SimpleVector , hardlimit:: Bool , si:: StmtInfo , sv:: InferenceState )
317- edge = ret. edge
318- if edge != = nothing
319- cache = CC. get (CC. code_cache (interp), edge, nothing )
320- if cache != = nothing
321- src = @atomic :monotonic cache. inferred
322- if isa (src, DAECache)
323- info = src. info
324- merge_daeinfo! (interp, sv. result, info)
315+ return Future {MethodCallResult} (mret, interp, sv) do ret, interp, sv
316+ edge = ret. edge
317+ if edge != = nothing
318+ cache = CC. get (CC. code_cache (interp), edge, nothing )
319+ if cache != = nothing
320+ src = @atomic :monotonic cache. inferred
321+ if isa (src, DAECache)
322+ info = src. info
323+ merge_daeinfo! (interp, sv. result, info)
324+ end
325325 end
326326 end
327+ return ret
327328 end
328- return ret
329329end
330330
331331@override function CC. const_prop_call (interp:: DAEInterpreter ,
443443
444444# TODO propagate debug configurations here
445445@override function CC. optimize (interp:: DAEInterpreter , opt:: OptimizationState , caller:: InferenceResult )
446- ir = CC. run_passes_ipo_safe (opt. src, opt, caller )
446+ ir = CC. run_passes_ipo_safe (opt. src, opt)
447447 ir = run_dae_passes (interp, ir)
448- CC. ipo_dataflow_analysis! (interp, ir, caller)
448+ CC. ipo_dataflow_analysis! (interp, opt, ir, caller)
449449 if interp. ipo_analysis_mode
450450 result = ipo_dae_analysis! (interp, ir, caller. linfo, caller)
451451 if result != = nothing
@@ -524,14 +524,10 @@ end
524524 src === nothing && return nothing
525525 (; inferred, ir) = src:: DAECache
526526 (isa (inferred, CodeInfo) && isa (ir, IRCode)) || return nothing
527- method_info = CC. MethodInfo (inferred)
527+ method_info = CC. SpecInfo (inferred)
528528 ir = copy (ir)
529529 (; min_world, max_world) = inferred
530- if Base. __has_internal_change (v " 1.12-alpha" , :codeinfonargs )
531- argtypes = CC. va_process_argtypes (CC. optimizer_lattice (interp), argtypes, inferred. nargs, inferred. isva)
532- elseif VERSION >= v " 1.12.0-DEV.341"
533- argtypes = CC. va_process_argtypes (CC. optimizer_lattice (interp), argtypes, mi)
534- end
530+ argtypes = CC. va_process_argtypes (CC. optimizer_lattice (interp), argtypes, inferred. nargs, inferred. isva)
535531 return IRInterpretationState (interp, method_info, ir, mi, argtypes,
536532 world, min_world, max_world)
537533end
@@ -974,34 +970,36 @@ function _abstract_eval_invoke_inst(interp::DAEInterpreter, inst::Union{CC.Instr
974970end
975971
976972@override function CC. abstract_eval_statement_expr (interp:: DAEInterpreter , inst:: Expr , vtypes:: Nothing , irsv:: IRInterpretationState )
977- (; rt, exct, effects) = @invoke CC. abstract_eval_statement_expr (interp:: AbstractInterpreter , inst:: Expr , vtypes:: Nothing , irsv:: IRInterpretationState )
978-
979- if (! interp. ipo_analysis_mode || interp. in_analysis) && ! isa (rt, Const) && ! isa (rt, Incidence) && ! CC. isType (rt) && ! is_all_inc_or_const (Any[rt])
980- argtypes = CC. collect_argtypes (interp, inst. args, nothing , irsv)
981- if argtypes === nothing
982- return CC. RTEffects (rt, exct, effects)
983- end
984- if is_all_inc_or_const (argtypes)
985- if inst. head in (:call , :invoke ) && CC. hasintersect (widenconst (argtypes[inst. head === :call ? 1 : 2 ]), Union{typeof (variable), typeof (sim_time), typeof (state_ddt)})
986- # The `variable` and `state_ddt` intrinsics can source Incidence. For all other
987- # calls, if there's no incidence in the arguments, there cannot be any incidence
988- # in the result.
973+ ret = @invoke CC. abstract_eval_statement_expr (interp:: AbstractInterpreter , inst:: Expr , vtypes:: Nothing , irsv:: IRInterpretationState )
974+ return Future {CC.RTEffects} (ret, interp, irsv) do ret, interp, irsv
975+ (; rt, exct, effects) = ret
976+ if (! interp. ipo_analysis_mode || interp. in_analysis) && ! isa (rt, Const) && ! isa (rt, Incidence) && ! CC. isType (rt) && ! is_all_inc_or_const (Any[rt])
977+ argtypes = CC. collect_argtypes (interp, inst. args, nothing , irsv)
978+ if argtypes === nothing
989979 return CC. RTEffects (rt, exct, effects)
990980 end
991- fb_inci = _fallback_incidence (argtypes)
992- if fb_inci != = nothing
993- update_type (t:: Type ) = Incidence (t, fb_inci. row, fb_inci. eps)
994- update_type (t:: Incidence ) = t
995- update_type (t:: Const ) = t
996- update_type (t:: CC.PartialTypeVar ) = t
997- update_type (t:: PartialStruct ) = PartialStruct (t. typ, Any[Base. isvarargtype (f) ? f : update_type (f) for f in t. fields])
998- update_type (t:: CC.Conditional ) = CC. Conditional (t. slot, update_type (t. thentype), update_type (t. elsetype))
999- newrt = update_type (rt)
1000- return CC. RTEffects (newrt, exct, effects)
981+ if is_all_inc_or_const (argtypes)
982+ if inst. head in (:call , :invoke ) && CC. hasintersect (widenconst (argtypes[inst. head === :call ? 1 : 2 ]), Union{typeof (variable), typeof (sim_time), typeof (state_ddt)})
983+ # The `variable` and `state_ddt` intrinsics can source Incidence. For all other
984+ # calls, if there's no incidence in the arguments, there cannot be any incidence
985+ # in the result.
986+ return CC. RTEffects (rt, exct, effects)
987+ end
988+ fb_inci = _fallback_incidence (argtypes)
989+ if fb_inci != = nothing
990+ update_type (t:: Type ) = Incidence (t, fb_inci. row, fb_inci. eps)
991+ update_type (t:: Incidence ) = t
992+ update_type (t:: Const ) = t
993+ update_type (t:: CC.PartialTypeVar ) = t
994+ update_type (t:: PartialStruct ) = PartialStruct (t. typ, Any[Base. isvarargtype (f) ? f : update_type (f) for f in t. fields])
995+ update_type (t:: CC.Conditional ) = CC. Conditional (t. slot, update_type (t. thentype), update_type (t. elsetype))
996+ newrt = update_type (rt)
997+ return CC. RTEffects (newrt, exct, effects)
998+ end
1001999 end
10021000 end
1001+ return CC. RTEffects (rt, exct, effects)
10031002 end
1004- return CC. RTEffects (rt, exct, effects)
10051003end
10061004
10071005@override function CC. compute_forwarded_argtypes (interp:: DAEInterpreter , arginfo:: ArgInfo , sv:: AbsIntState )
@@ -1218,11 +1216,12 @@ function infer_ir!(ir, interp::AbstractInterpreter, mi::MethodInstance)
12181216 end
12191217 end
12201218
1221- method_info = CC. MethodInfo (#= propagate_inbounds=# true , nothing )
1219+ (nargs, isva) = isa (mi. def, Method) ? (mi. def. nargs, mi. def. isva) : (0 , false )
1220+ method_info = CC. SpecInfo (nargs, isva, #= propagate_inbounds=# true , nothing )
12221221 min_world = world = get_inference_world (interp)
12231222 max_world = get_world_counter ()
12241223 irsv = IRInterpretationState (interp, method_info, ir, mi, ir. argtypes, world, min_world, max_world)
1225- (rt, nothrow) = CC. _ir_abstract_constant_propagation (interp, irsv)
1224+ (rt, nothrow) = CC. ir_abstract_constant_propagation (interp, irsv)
12261225 return rt
12271226end
12281227
0 commit comments