@@ -461,6 +461,7 @@ function CC.abstract_call_known(interp::AbstractGPUInterpreter, @nospecialize(f)
461461end
462462
463463# Use the Inlining infrastructure to perform our refinement
464+ # TODO : @aviatesk This is not reached on 1.11
464465function CC. handle_call! (todo:: Vector{Pair{Int,Any}} ,
465466 ir:: CC.IRCode , idx:: CC.Int , stmt:: Expr , info:: DeferredCallInfo , flag:: UInt8 , sig:: CC.Signature ,
466467 state:: CC.InliningState )
@@ -495,12 +496,11 @@ struct DeferredEdges
495496 edges:: Vector{MethodInstance}
496497end
497498
498- function CC . ipo_dataflow_analysis! (interp :: AbstractGPUInterpreter , ir:: CC.IRCode , caller :: CC.InferenceResult )
499+ function find_deferred_edges ( ir:: CC.IRCode )
499500 edges = MethodInstance[]
500- # @aviateks : Can we add this instead in handle_call
501+ # @aviatesk : Can we add this instead in handle_call
501502 for stmt in ir. stmts
502503 inst = stmt[:inst ]
503- @show inst
504504 inst isa Expr || continue
505505 expr = inst:: Expr
506506 if expr. head === :foreigncall &&
@@ -510,11 +510,29 @@ function CC.ipo_dataflow_analysis!(interp::AbstractGPUInterpreter, ir::CC.IRCode
510510 end
511511 end
512512 unique! (edges)
513+ return edges
514+ end
515+
516+ if VERSION >= v " 1.11.0-"
517+ # stack_analysis_result and ipo_dataflow_analysis is 1.11 only
518+ function CC. ipo_dataflow_analysis! (interp:: AbstractGPUInterpreter , ir:: CC.IRCode , caller:: CC.InferenceResult )
519+ edges = find_deferred_edges (ir)
513520 if ! isempty (edges)
514521 CC. stack_analysis_result! (caller, DeferredEdges (edges))
515522 end
516523 @invoke CC. ipo_dataflow_analysis! (interp:: CC.AbstractInterpreter , ir:: CC.IRCode , caller:: CC.InferenceResult )
517524end
525+ else
526+ # v1.10.0
527+ function CC. finish (interp:: AbstractGPUInterpreter , opt:: CC.OptimizationState , ir:: CC.IRCode , caller:: CC.InferenceResult )
528+ edges = find_deferred_edges (ir)
529+ if ! isempty (edges)
530+ # This is a tad bit risky, but nobody should be running EA on our results.
531+ caller. argescapes = DeferredEdges (edges)
532+ end
533+ @invoke CC. finish (interp:: CC.AbstractInterpreter , opt:: CC.OptimizationState , ir:: CC.IRCode , caller:: CC.InferenceResult )
534+ end
535+ end
518536
519537# # world view of the cache
520538using Core. Compiler: WorldView
@@ -797,10 +815,16 @@ function compile_method_instance(@nospecialize(job::CompilerJob), compiled::IdDi
797815 outstanding = Any[]
798816 for mi in method_instances
799817 ci = compiled[mi]. ci
800- edges = CC. traverse_analysis_results (ci) do @nospecialize result
801- return result isa DeferredEdges ? result : return
818+ @static if VERSION >= v " 1.11.0-"
819+ edges = CC. traverse_analysis_results (ci) do @nospecialize result
820+ return result isa DeferredEdges ? result : return
821+ end
822+ else
823+ edges = ci. argescapes
824+ if ! (edges isa Union{Nothing, DeferredEdges})
825+ edges = nothing
826+ end
802827 end
803- @show edges
804828 if edges != = nothing
805829 for deferred_mi in (edges:: DeferredEdges ). edges
806830 if ! haskey (compiled, deferred_mi)
0 commit comments