Skip to content

Commit 448a8e1

Browse files
committed
WIP: Try to process gpuc.lookup early
1 parent b04f2f2 commit 448a8e1

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
@@ -751,6 +751,26 @@ function compile_method_instance(@nospecialize(job::CompilerJob))
751751
compiled[mi] = (; ci, func=llvm_func, specfunc=llvm_specfunc)
752752
end
753753

754+
# We don't control the interp that codegen constructs for us above.
755+
# So we have to scan the IR manually.
756+
for (mi, (ci::CodeInstance, _, _)) in compiled
757+
src = @atomic :monotonic ci.inferred
758+
if src isa String
759+
src = Core.Compiler._uncompressed_ir(mi.def, src)
760+
end
761+
for expr in src.code
762+
expr isa Expr || continue
763+
if expr.head === :foreigncall &&
764+
expr.args[1] == "extern gpuc.lookup"
765+
deferred_mi = expr.args[6]
766+
# Now push to a worklist and process...
767+
# TODO: How do we deal with call duplication?
768+
# Can we codegen into the same module, or do we merge?
769+
# we can check against "compiled" to avoid recursion?
770+
end
771+
end
772+
end
773+
754774
# ensure that the requested method instance was compiled
755775
@assert haskey(compiled, job.source)
756776

0 commit comments

Comments
 (0)