Skip to content

Commit 82de09c

Browse files
committed
make things work on 1.10
1 parent 22198e7 commit 82de09c

File tree

1 file changed

+30
-6
lines changed

1 file changed

+30
-6
lines changed

src/jlgen.jl

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ function CC.abstract_call_known(interp::AbstractGPUInterpreter, @nospecialize(f)
486486
end
487487

488488
# Use the Inlining infrastructure to perform our refinement
489+
# TODO: @aviatesk This is not reached on 1.11
489490
function CC.handle_call!(todo::Vector{Pair{Int,Any}},
490491
ir::CC.IRCode, idx::CC.Int, stmt::Expr, info::DeferredCallInfo, flag::UInt8, sig::CC.Signature,
491492
state::CC.InliningState)
@@ -520,12 +521,11 @@ struct DeferredEdges
520521
edges::Vector{MethodInstance}
521522
end
522523

523-
function CC.ipo_dataflow_analysis!(interp::AbstractGPUInterpreter, ir::CC.IRCode, caller::CC.InferenceResult)
524+
function find_deferred_edges(ir::CC.IRCode)
524525
edges = MethodInstance[]
525-
# @aviateks: Can we add this instead in handle_call
526+
# @aviatesk: Can we add this instead in handle_call
526527
for stmt in ir.stmts
527528
inst = stmt[:inst]
528-
@show inst
529529
inst isa Expr || continue
530530
expr = inst::Expr
531531
if expr.head === :foreigncall &&
@@ -535,11 +535,29 @@ function CC.ipo_dataflow_analysis!(interp::AbstractGPUInterpreter, ir::CC.IRCode
535535
end
536536
end
537537
unique!(edges)
538+
return edges
539+
end
540+
541+
if VERSION >= v"1.11.0-"
542+
# stack_analysis_result and ipo_dataflow_analysis is 1.11 only
543+
function CC.ipo_dataflow_analysis!(interp::AbstractGPUInterpreter, ir::CC.IRCode, caller::CC.InferenceResult)
544+
edges = find_deferred_edges(ir)
538545
if !isempty(edges)
539546
CC.stack_analysis_result!(caller, DeferredEdges(edges))
540547
end
541548
@invoke CC.ipo_dataflow_analysis!(interp::CC.AbstractInterpreter, ir::CC.IRCode, caller::CC.InferenceResult)
542549
end
550+
else
551+
# v1.10.0
552+
function CC.finish(interp::AbstractGPUInterpreter, opt::CC.OptimizationState, ir::CC.IRCode, caller::CC.InferenceResult)
553+
edges = find_deferred_edges(ir)
554+
if !isempty(edges)
555+
# This is a tad bit risky, but nobody should be running EA on our results.
556+
caller.argescapes = DeferredEdges(edges)
557+
end
558+
@invoke CC.finish(interp::CC.AbstractInterpreter, opt::CC.OptimizationState, ir::CC.IRCode, caller::CC.InferenceResult)
559+
end
560+
end
543561

544562
## world view of the cache
545563
using Core.Compiler: WorldView
@@ -863,10 +881,16 @@ function compile_method_instance(@nospecialize(job::CompilerJob), compiled::IdDi
863881
outstanding = Any[]
864882
for mi in method_instances
865883
ci = compiled[mi].ci
866-
edges = CC.traverse_analysis_results(ci) do @nospecialize result
867-
return result isa DeferredEdges ? result : return
884+
@static if VERSION >= v"1.11.0-"
885+
edges = CC.traverse_analysis_results(ci) do @nospecialize result
886+
return result isa DeferredEdges ? result : return
887+
end
888+
else
889+
edges = ci.argescapes
890+
if !(edges isa Union{Nothing, DeferredEdges})
891+
edges = nothing
892+
end
868893
end
869-
@show edges
870894
if edges !== nothing
871895
for deferred_mi in (edges::DeferredEdges).edges
872896
if !haskey(compiled, deferred_mi)

0 commit comments

Comments
 (0)