Repository navigation
Conversation
…odule The driver for compilers with their own interpreter (GPUCompiler.jl, Enzyme.jl), as Julia's `jl_emit_native` is for them. It takes `(ci, src)` pairs, where `src` is the CodeInfo or IRCode the caller inferred. - Every function's IR comes from the set, with its CodeInstance's return type. A callee outside the set follows `on_unsupported`: it calls native code, recorded as a fallback, or it throws. - Functions that always throw are compiled, not stubbed. - It returns each CodeInstance's jlcall and specsig entries (`CompiledFunctions`) and the `CodegenOutput`. To support this: - `CGModule` takes the IR source (`ir_source`, by default native inference) and `throwing_stubs`. - A callee whose IR the source can't provide follows the failure policy. - `CodegenConfig` gains `gcstack_arg` (specsig entries without the pgcstack, in the C calling convention) and `safepoint_on_entry`, as Julia's `CodegenParams`; GPU targets turn both off. `@cfunction` keeps the runtime's convention. The tests use an interpreter with an overlay method table: its methods are the ones compiled. They run a differential corpus through `emit_into!`, and check the specsig declarations against native code with the same `CodegenParams`, calling the C entry directly, plus missing callees and always-throwing callees. Assisted-by: Claude Code (Opus 5.5)
vchuravy
force-pushed
the
vc/jc-18-emit-into
branch
from
October 19, 2026 16:20
e662430 to
0f02374
Compare
vchuravy
force-pushed
the
vc/jc-17-output
branch
from
October 19, 2026 16:20
e89007f to
12acfc0
Compare
The jlcall and specsig entries call their function with `alwaysinline`, so that after any pipeline's always-inliner (Julia's, GPUCompiler's), an entry is the function itself, as native code's are. With GPUCompiler, the specsig entry of a kernel otherwise stayed a call of the kernel's body. Assisted-by: Claude Code (Opus 5.5)
The specsig entry of a CodeInstance is `julia_f_N` and its jlcall entry `jfptr_f_N`, as Julia's code generator names them; the function they inline is `jlbody_f_N`. GPUCompiler's tests, and whoever else matches the names, see the same functions with either code generator. Assisted-by: Claude Code (Opus 5.5)
Functions that other functions call keep native code's name `julia_f_N`, as calls that aren't inlined refer to them; the specsig entry is `j_f_N`, the prefix of native code's specsig wrappers. Assisted-by: Claude Code (Opus 5.5)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #18. This is the GPUCompiler.jl/Enzyme.jl entry point (plan P4), the JuliaCodegen counterpart of the
jl_emit_nativecall in GPUCompiler'scompile_method_instance.There is also
emit_into!(cgm, codeinfos)for an existingCGModule.inflate_irfor aCodeInfo), with its CodeInstance'srettype.:invokes of the set's CodeInstances call their functions.on_unsupported: with:fallbackthey call native code and are recorded inoutput.fallbacks; with:errorthey throw.specsig_abihandles the signature, a specsig entry. Both have external linkage; the bodies are internal. GPUCompiler reads the samefunc/specfuncpair fromjl_emit_nativetoday.Supporting changes
CGModule(mod, config; ir_source=get_ir, throwing_stubs=true). A callee whose IR the source can't provide now follows the failure policy instead of always becoming a stub. The existing suite is unaffected.CodegenConfig(; gcstack_arg=true, safepoint_on_entry=true)mirrors Julia'sCodegenParams. GPUCompiler sets both tofalse. Withgcstack_arg=false, specsig entries have no pgcstack argument and use the C calling convention.@cfunctionalways uses the runtime's convention, which passes the pgcstack.Tests (
test/emit_into.jl)They use a small
AbstractInterpreterwith an overlay method table, standing in for GPUCompiler's, plus a transitive(ci, src)collector.ei_kernel(3) == 602; native gives 8.emit_into!: recursion, loops over arrays, error paths,try/catch, aggregates.code_llvmwithCodegenParams(gcstack_arg=false, safepoint_on_entry=false), and the code has no safepoints. The specsig entry is called directly withccallas a C function.Known gap: varargs callees (e.g. string interpolation in an error message) are still stubs that call native code. They show up in
output.fallbacks.Tested locally with
julia +1.12,+1.13and+nightly: 6935, 6941 and 6940 tests pass.🤖 Generated with Claude Code