@@ -462,48 +462,28 @@ function CC.abstract_call_known(interp::GPUInterpreter, @nospecialize(f),
462462 max_methods:: Int )
463463end
464464
465- # Customize the optimization pipeline
466- Base. iterate (compact:: CC.IncrementalCompact , state= nothing ) = CC. iterate (compact, state)
467- Base. getindex (compact:: CC.IncrementalCompact , idx) = CC. getindex (compact, idx)
468-
469- function deferred_pass! (ir)
470- compact = CC. IncrementalCompact (ir)
471- for ((old_idx, idx), stmt) in compact
472- if CC. is_known_call (stmt, var"gpuc.deferred" , compact)
473- @safe_show stmt
474- end
475- end
476- CC. non_dce_finish! (compact)
477- CC. simple_dce! (compact)
478- ir = CC. complete (compact)
479- return ir
480- end
481-
482- function CC. optimize (interp:: GPUInterpreter , opt:: CC.OptimizationState , caller:: CC.InferenceResult )
483- CC. @timeit " optimizer" ir = CC. run_passes (opt. src, opt, caller)
484- # Customizing the ipo_safe pipeline is a pain
485- ir = deferred_pass! (ir)
486- @static if VERSION >= v " 1.11.0-"
487- CC. ipo_dataflow_analysis! (interp, ir, caller)
488- end
489- return CC. finish (interp, opt, ir, caller)
490- end
491-
492- function CC. typeinf_ircode (interp:: GPUInterpreter , mi:: CC.MethodInstance ,
493- optimize_until:: Union{Integer,AbstractString,Nothing} )
494- start_time = ccall (:jl_typeinf_timing_begin , UInt64, ())
495- frame = CC. typeinf_frame (interp, mi, false )
496- if frame === nothing
497- ccall (:jl_typeinf_timing_end , Cvoid, (UInt64,), start_time)
498- return nothing , Any
465+ # Use the Inlining infrastructure to perform our refinement
466+ function CC. handle_call! (todo:: Vector{Pair{Int,Any}} ,
467+ ir:: CC.IRCode , idx:: CC.Int , stmt:: Expr , info:: DeferredCallInfo , flag:: UInt8 , sig:: CC.Signature ,
468+ state:: CC.InliningState )
469+
470+ minfo = info. info
471+ results = minfo. results
472+ if length (results. matches) != 1
473+ return nothing
499474 end
500- (; result) = frame
501- opt = CC. OptimizationState (frame, interp)
502- ir = CC. run_passes (opt. src, opt, result, optimize_until)
503- ir = deferred_pass! (ir)
504- rt = CC. widenconst (CC. ignorelimited (result. result))
505- ccall (:jl_typeinf_timing_end , Cvoid, (UInt64,), start_time)
506- return ir, rt
475+ match = only (results. matches)
476+
477+ # lookup the target mi with correct edge tracking
478+ case = CC. compileable_specialization (match, CC. Effects (), CC. InliningEdgeTracker (state), info)
479+ @assert case isa CC. InvokeCase
480+ @assert stmt. head === :call
481+
482+ # rewrite the marker function
483+ stmt. args[1 ] = var"gpuc.lookup"
484+ # insert the mi
485+ insert! (stmt. args, 2 , case. invoke)
486+ return nothing
507487end
508488
509489# # world view of the cache
0 commit comments