Use Julia dialect internally - #62938
Draft
vchuravy wants to merge 6 commits into
Draft
Conversation
vchuravy
force-pushed
the
vc/llvm-dialects-internal-usage
branch
from
August 31, 2026 15:08
0f035e7 to
28bf4ec
Compare
vchuravy
commented
Aug 31, 2026
| @@ -349,7 +349,7 @@ bool Optimizer::isSafepoint(Instruction *inst) | |||
| if (auto callee = call->getCalledFunction()) { | |||
| // Known functions emitted in codegen that are not safepoints | |||
| if (callee == pass.pointer_from_objref_func | |||
Member
Author
There was a problem hiding this comment.
This should also be a dialect op
vchuravy
force-pushed
the
vc/llvm-dialects-internal-usage
branch
2 times, most recently
from
August 31, 2026 17:52
7cce10a to
b605614
Compare
vchuravy
force-pushed
the
vc/llvm-dialects-internal-usage
branch
from
August 31, 2026 18:17
b605614 to
3b5aa5c
Compare
vchuravy
force-pushed
the
vc/llvm-dialects-internal-usage
branch
from
August 31, 2026 18:48
3b5aa5c to
0044949
Compare
Codegen builds the pseudo-intrinsics via llvm_dialects::Builder::create<Op> and the passes recognize them with isa<Op>(call) instead of string or function pointer comparisons. The llvm_dialects::DialectContext required for op construction is owned by jl_codegen_output_t, giving it exactly the lifetime of the module emission state and keeping it inside the invalidation contract of llvm-dialects' per-thread context cache. The AddressSpace enum moves into the julia namespace next to the dialect; the GC-rooting static analysis treats the julia and llvm_dialects namespaces as safepoint-free, like the llvm namespace. llvmcalltest.cpp includes llvm-codegen-shared.h and with it JuliaDialect.h, so the test library depends on the tblgen-generated headers. Assisted-by: Claude Code (Fable 5) Claude-Session: https://claude.ai/code/session_013iurq91jyFwfKN8EbrcjL2
Switch codegen to building julia.typeof, julia.blackbox, julia.write_barrier, julia.cancellation_point, julia.gcroot_flush, julia.pointer_from_objref, the julia.call trampoline family, and julia.gc_alloc_obj via llvm_dialects::Builder. The handwritten JuliaFunction declarations are removed; emit_jlcall selects the trampoline with an enum instead of JuliaFunction pointers. The GC invariant verifier recognizes the variadic ops (write_barrier, the call family) via the generated op classes and skips their fixed leading arguments by op kind rather than by declared parameter count. Assisted-by: Claude Code (Fable 5) Claude-Session: https://claude.ai/code/session_013iurq91jyFwfKN8EbrcjL2
Replace the single-owner llvm_dialects::DialectContext in jl_codegen_output_t with julia::ScopedDialects, an RAII attachment backed by a per-context refcounted registry. This lets the emission state and the optimization passes attach the dialect to the same LLVMContext independently; the last detachment destroys the underlying DialectContext and erases the registry entry, so a reused context address starts clean. Assisted-by: Claude Code (Fable 5) Claude-Session: https://claude.ai/code/session_01C5vc8DuxsFWuP2UZGN4CCe
LateLowerGCFrame now creates julia.new_gc_frame, julia.push_gc_frame, julia.get_gc_frame_slot, and julia.pop_gc_frame via llvm_dialects::Builder, as do the queue_gc_root slow path in stock final GC lowering and the julia.safepoint emission shared by the passes. The GC lowering passes attach the dialect with a ScopedDialects for the duration of their run. julia.gc_alloc_bytes keeps its runtime-typed declaration: its size parameter type is target dependent and the allocsize attribute requires a non-varargs declaration, neither of which llvm-dialects can express yet. Assisted-by: Claude Code (Fable 5)
Add a JuliaDialectsVerifier module pass wrapping llvm_dialects::verify and run it with the other verification passes (FORCE_ASSERTIONS builds), so ill-formed uses of Julia dialect ops are caught at the pipeline boundary. The pass is also registered for opt-based testing. Assisted-by: Claude Code (Fable 5)
Convert the last two pseudo-intrinsics outside the dialect: codegen emits `llvm.julia.gc_preserve_begin`/`_end` through the generated builders, the passes recognize them with isa<julia::GCPreserveBegin/ GCPreserveEnd>, and AllocOpt recreates shrunken preserve regions through the dialect builder (attaching the dialect for the duration of the pass). The gc_preserve_begin_func/gc_preserve_end_func fields of JuliaPassContext and their add_named_global registrations are retired; only jl_pop_handler_noexcept, a plain runtime function, remains. Assisted-by: Claude Code (Fable 5) Claude-Session: https://claude.ai/code/session_01C5vc8DuxsFWuP2UZGN4CCe
vchuravy
force-pushed
the
vc/llvm-dialects-internal-usage
branch
from
August 31, 2026 19:08
0044949 to
efa5083
Compare
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.
Mechanical replacement and using the Julia dialect introduced up the stack.
Assisted-by: Claude
Stack created with GitHub Stacks CLI • Give Feedback 💬