Skip to content

Commit ad1d6c6

Browse files
committed
WIP: Try to process gpuc.lookup early
1 parent 43adce8 commit ad1d6c6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/jlgen.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,26 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
817817
compiled[mi] = (; ci, func=llvm_func, specfunc=llvm_specfunc)
818818
end
819819

820+
# We don't control the interp that codegen constructs for us above.
821+
# So we have to scan the IR manually.
822+
for (mi, (ci::CodeInstance, _, _)) in compiled
823+
src = @atomic :monotonic ci.inferred
824+
if src isa String
825+
src = Core.Compiler._uncompressed_ir(mi.def, src)
826+
end
827+
for expr in src.code
828+
expr isa Expr || continue
829+
if expr.head === :foreigncall &&
830+
expr.args[1] == "extern gpuc.lookup"
831+
deferred_mi = expr.args[6]
832+
# Now push to a worklist and process...
833+
# TODO: How do we deal with call duplication?
834+
# Can we codegen into the same module, or do we merge?
835+
# we can check against "compiled" to avoid recursion?
836+
end
837+
end
838+
end
839+
820840
# ensure that the requested method instance was compiled
821841
@assert haskey(compiled, job.source)
822842

0 commit comments

Comments
 (0)