@@ -487,48 +487,28 @@ function CC.abstract_call_known(interp::GPUInterpreter, @nospecialize(f),
487487 max_methods:: Int )
488488end
489489
490- # Customize the optimization pipeline
491- Base. iterate (compact:: CC.IncrementalCompact , state= nothing ) = CC. iterate (compact, state)
492- Base. getindex (compact:: CC.IncrementalCompact , idx) = CC. getindex (compact, idx)
493-
494- function deferred_pass! (ir)
495- compact = CC. IncrementalCompact (ir)
496- for ((old_idx, idx), stmt) in compact
497- if CC. is_known_call (stmt, var"gpuc.deferred" , compact)
498- @safe_show stmt
499- end
500- end
501- CC. non_dce_finish! (compact)
502- CC. simple_dce! (compact)
503- ir = CC. complete (compact)
504- return ir
505- end
506-
507- function CC. optimize (interp:: GPUInterpreter , opt:: CC.OptimizationState , caller:: CC.InferenceResult )
508- CC. @timeit " optimizer" ir = CC. run_passes (opt. src, opt, caller)
509- # Customizing the ipo_safe pipeline is a pain
510- ir = deferred_pass! (ir)
511- @static if VERSION >= v " 1.11.0-"
512- CC. ipo_dataflow_analysis! (interp, ir, caller)
513- end
514- return CC. finish (interp, opt, ir, caller)
515- end
516-
517- function CC. typeinf_ircode (interp:: GPUInterpreter , mi:: CC.MethodInstance ,
518- optimize_until:: Union{Integer,AbstractString,Nothing} )
519- start_time = ccall (:jl_typeinf_timing_begin , UInt64, ())
520- frame = CC. typeinf_frame (interp, mi, false )
521- if frame === nothing
522- ccall (:jl_typeinf_timing_end , Cvoid, (UInt64,), start_time)
523- return nothing , Any
490+ # Use the Inlining infrastructure to perform our refinement
491+ function CC. handle_call! (todo:: Vector{Pair{Int,Any}} ,
492+ ir:: CC.IRCode , idx:: CC.Int , stmt:: Expr , info:: DeferredCallInfo , flag:: UInt8 , sig:: CC.Signature ,
493+ state:: CC.InliningState )
494+
495+ minfo = info. info
496+ results = minfo. results
497+ if length (results. matches) != 1
498+ return nothing
524499 end
525- (; result) = frame
526- opt = CC. OptimizationState (frame, interp)
527- ir = CC. run_passes (opt. src, opt, result, optimize_until)
528- ir = deferred_pass! (ir)
529- rt = CC. widenconst (CC. ignorelimited (result. result))
530- ccall (:jl_typeinf_timing_end , Cvoid, (UInt64,), start_time)
531- return ir, rt
500+ match = only (results. matches)
501+
502+ # lookup the target mi with correct edge tracking
503+ case = CC. compileable_specialization (match, CC. Effects (), CC. InliningEdgeTracker (state), info)
504+ @assert case isa CC. InvokeCase
505+ @assert stmt. head === :call
506+
507+ # rewrite the marker function
508+ stmt. args[1 ] = var"gpuc.lookup"
509+ # insert the mi
510+ insert! (stmt. args, 2 , case. invoke)
511+ return nothing
532512end
533513
534514# # world view of the cache
0 commit comments