Repository navigation
Generate inline asm and IR helpers with LLVM.jl 10's @llvmgenerated - #175
Draft
AntonOresten wants to merge 1 commit into
Draft
AntonOresten wants to merge 1 commit into
AntonOresten wants to merge 1 commit into
Conversation
Build the convergent and plain inline-asm calls with `generate_llvmcall` instead of hand-written IR strings: the builder attaches the call-site attributes `@asmcall` cannot (`convergent nomerge nounwind`), LLVM.jl derives the signature, handles typed and opaque pointers, and verifies the IR. Wrappers now call `convergent_asmcall`/`plain_asmcall` directly and get back the call expression. `reinterpret_addrspace`, the vector global loads/stores and the mma half-vector bitcasts become `@llvmgenerated` functions. Requires LLVM.jl 10. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This was referenced Oct 5, 2026
Merged
This branch has not been deployed
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.
Switches PTX's hand-written LLVM IR strings to LLVM.jl 10's
generate_llvmcall/@llvmgenerated(JuliaLLVM/LLVM.jl#596; cf. JuliaGPU/CUDA.jl#3305).convergent_asmcall/plain_asmcallbuild the asm call with anIRBuilderand attach the call-site attributes@asmcallcan't (convergent nomerge nounwind). LLVM.jl derives the signature from the Julia types, handles typed (Julia 1.10/1.11) and opaque pointers, and verifies the IR at generation time. Wrappers get back the call expression and splice it into@eval, replacing the*_asm_irstring builders.@llvmgeneratedhelpers:reinterpret_addrspace, vector globalld/st(_vec_load/_vec_store), and the mma half-vector bitcasts.LLVM = "10". That pulls in CUDA.jl ≥ 6.4.2 / GPUCompiler ≥ 2.11.llvmcall_irintest/setup.jl).Net −115 lines.
Precompile time
This is the open question.
Base.compilecache(PTX), 3 runs each on LLVM.jl 10.0.0 / Julia 1.13:Most of the gap comes from
generate_llvmcallassigning every argument expression to a temporary before thellvmcall. PTX expands thousands of these, many with 100+ arguments (wgmma/mma), and lowering all those assignments is the cost. When I stripped the temporaries as an experiment, the module body matched main. The temporaries are only needed when an argument is dropped (static/singleton): when every argument is passed through,llvmcallalready evaluates them once, in order. I plan to propose that change upstream. Specializations of the asm helpers on hundreds of distinct tuple types were a ~3 s regression of their own; that's already fixed here.Testing
host/conformance. That failure is unrelated: a fresh resolve picksNVPTX_LLVM_Backend_jll23.1.2, but the registry was generated against 23.1.1, so main hits it too.🤖 Generated with Claude Code