@@ -516,6 +516,31 @@ function CC.handle_call!(todo::Vector{Pair{Int,Any}},
516
516
return nothing
517
517
end
518
518
519
+ struct DeferredEdges
520
+ edges:: Vector{MethodInstance}
521
+ end
522
+
523
+ function CC. ipo_dataflow_analysis! (interp:: AbstractGPUInterpreter , ir:: CC.IRCode , caller:: CC.InferenceResult )
524
+ edges = MethodInstance[]
525
+ # @aviateks: Can we add this instead in handle_call
526
+ for stmt in ir. stmts
527
+ inst = stmt[:inst ]
528
+ @show inst
529
+ inst isa Expr || continue
530
+ expr = inst:: Expr
531
+ if expr. head === :foreigncall &&
532
+ expr. args[1 ] == " extern gpuc.lookup"
533
+ deferred_mi = expr. args[6 ]
534
+ push! (edges, deferred_mi)
535
+ end
536
+ end
537
+ unique! (edges)
538
+ if ! isempty (edges)
539
+ CC. stack_analysis_result! (caller, DeferredEdges (edges))
540
+ end
541
+ @invoke CC. ipo_dataflow_analysis! (interp:: CC.AbstractInterpreter , ir:: CC.IRCode , caller:: CC.InferenceResult )
542
+ end
543
+
519
544
# # world view of the cache
520
545
using Core. Compiler: WorldView
521
546
@@ -834,20 +859,16 @@ function compile_method_instance(@nospecialize(job::CompilerJob), compiled::IdDi
834
859
compiled[mi] = (; ci, func= llvm_func, specfunc= llvm_specfunc)
835
860
end
836
861
837
- # We don't control the interp that codegen constructs for us above.
838
- # So we have to scan the IR manually.
862
+ # Collect the deferred edges
839
863
outstanding = Any[]
840
864
for mi in method_instances
841
865
ci = compiled[mi]. ci
842
- src = @atomic :monotonic ci. inferred
843
- if src isa String
844
- src = Core. Compiler. _uncompressed_ir (mi. def, src)
866
+ edges = CC. traverse_analysis_results (ci) do @nospecialize result
867
+ return result isa DeferredEdges ? result : return
845
868
end
846
- for expr in src. code
847
- expr isa Expr || continue
848
- if expr. head === :foreigncall &&
849
- expr. args[1 ] == " extern gpuc.lookup"
850
- deferred_mi = expr. args[6 ]
869
+ @show edges
870
+ if edges != = nothing
871
+ for deferred_mi in (edges:: DeferredEdges ). edges
851
872
if ! haskey (compiled, deferred_mi)
852
873
push! (outstanding, deferred_mi)
853
874
end
0 commit comments