Repository navigation
Smaller tslang.exe: only the MLIR extensions and LLVM backends the compiler uses - #839
Merged
Merged
Conversation
registerAllExtensions referenced every upstream dialect's extension (GPU, NVVM, ROCDL, linalg, vector, sparse tensor, the transform dialect's), keeping ~14 MB of code nothing runs. Register the to-LLVM interfaces of the dialects tslang loads (arith, cf, func, index, math) and the func extensions only. Release tslang.exe: 87.8 MB -> 73.3 MB. ctest Release: 6976 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AllTargets* linked every backend LLVM was built with, and llvm::InitializeAllTargets() referenced them all. The official prebuilt LLVM a release links also has RISCV, BPF and NVPTX, which no tslang target uses. TSLANG_TARGETS (CMake) names the backends, each linked only when LLVM has it, and tslang.cpp initializes the same list. tslang.exe on the official LLVM 22.1.8 package: 83.8 MB -> 71.4 MB (and with the previous commit, ~98 MB -> 71.4 MB). A local LLVM with exactly these four backends is unchanged. ctest Release on the official package: 7064 passed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
Makes the compiler executable smaller: a release
tslang.exegoes from about 98 MB to 71.4 MB.registerAllExtensionsreferenced the extension of every upstream dialect (GPU, NVVM, ROCDL, linalg, vector, sparse tensor, the transform dialect's...), so the linker kept ~14 MB of code nothing runs.createMLIRContextnow registers the to-LLVM interfaces of the dialects it loads (arith, cf, func, index, math) and the func extensions only. tslang's lowering already calls those patterns directly.AllTargets*plusllvm::InitializeAllTargets()linked every backend LLVM was built with. The official LLVM package the release downloads also has RISCV, BPF and NVPTX.TSLANG_TARGETS(CMake cache variable) names the backends; each is linked only when LLVM has it, andtslang.cppinitializes the same list (TSLANG_TARGET_<NAME>definitions).Measurements (Windows x64 Release)
The ~98 MB baseline on the official package is estimated as the 83.8 MB build plus the ~14 MB the extensions change removes on the local build; it was not built on the official package.
Where the size was, from a link map of the local build: LLVM 52 MB, MLIR 27 MB (MLIRTypeScript 5.6 MB), clang 3.5 MB, rest 4 MB.
Testing
ctest -C Releaseagainst the official prebuilt LLVM + MLIR archive (as create-release does): 7064 passed.ctest -C Releaseagainst the local custom LLVM: 6976 passed on the first commit. On the final branch, the whole suite was not re-run end to end: a first run had 35 failures from stale runtime/helper targets, and after a full rebuild those 35 were re-run and all passed.test-own-err-own_err_iface_field_result, on the build without the backends commit; it passed 10/10 when repeated alone, so it looks flaky.Notes for reviewers
--mtriple=riscv64) is no longer possible with a release build; nothing in tests or docs uses one. Adding a backend is one entry inTSLANG_TARGETSplus one line ininitializeTargets()./GLobjects only link with the exact MSVC build that compiled them.🤖 Generated with Claude Code