[Meta] Reduce LLVM binary size
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
This issue tracks a workstream to reduce the size of LLVM tool binaries without removing tools, targets, features, or supported behavior.
The patches are intended to remain independently reviewable and performance-neutral. The main techniques include:
- packing generated tables and core data layouts where field ranges permit narrower representations;
- pooling repeated strings, masks, descriptors, instruction metadata, and generated table rows;
- outlining duplicate template and AST visitor implementations;
- retaining direct or constant-time lookup behavior where it matters;
- measuring affected standalone tools as well as the downstream all-tools multicall binary;
- adding compile-time assertions for core type layouts and narrowed field limits;
- validating with existing LLVM tests, byte-for-byte output comparisons, exhaustive generated-table reconstruction where applicable, and focused performance benchmarks.
On a downstream Darwin arm64 release build, the cumulative work completed so far reduces the all-tools multicall binary from 187,395,664 bytes to 161,283,216 bytes, a reduction of 26,112,448 bytes (about 13.9%). Individual upstream pull requests are measured independently against appropriate baselines; their reported deltas should not be summed directly because composition, alignment, and linker folding affect the aggregate result.
This issue tracks the independently reviewable patches in that workstream. All linked pull requests are initially drafts for manual review.
Status: [x] means merged, [DRAFT] means open as a draft, and strikethrough means closed without merging.
## Target-generated tables and MC metadata
- [x] [Coalesce the AArch64 perfect-shuffle table](https://github.com/llvm/llvm-project/pull/202617)
- [x] [Compact AArch64 scalable-vector intrinsic maps](https://github.com/llvm/llvm-project/pull/202618)
- [x] [Pool duplicate code-emitter base encodings](https://github.com/llvm/llvm-project/pull/202619)
- [ ] [Intern custom assembly operand match sequences](https://github.com/llvm/llvm-project/pull/202620)
- [ ] [Pool generated assembly matcher class sequences](https://github.com/llvm/llvm-project/pull/202621)
- [ ] [DRAFT] [Compact two-word APInt encoder tables](https://github.com/llvm/llvm-project/pull/202630)
- [ ] [DRAFT] [Compress generated instruction name tables](https://github.com/llvm/llvm-project/pull/202643)
- [ ] [Pack MCInstrDesc fields into 24 bytes](https://github.com/llvm/llvm-project/pull/202647)
- [ ] [DRAFT] [Pack generated MCOperandInfo sequences](https://github.com/llvm/llvm-project/pull/202648)
- [ ] [Pack scheduling class entry counts](https://github.com/llvm/llvm-project/pull/202649)
- [ ] [DRAFT] [Compress register-class subregister tables](https://github.com/llvm/llvm-project/pull/202658)
- [ ] [DRAFT] [Pool duplicate scheduling class descriptors](https://github.com/llvm/llvm-project/pull/202659)
- [ ] [DRAFT] [Pool subtarget feature masks](https://github.com/llvm/llvm-project/pull/202664)
- [x] [Pool sparse X86 disassembler opcode rows](https://github.com/llvm/llvm-project/pull/202666)
- [ ] [DRAFT] [Store itinerary cycles as uint8_t](https://github.com/llvm/llvm-project/pull/203131)
## SelectionDAG and GlobalISel
- [ ] [DRAFT] [Encode frequent ISD opcode checks directly](https://github.com/llvm/llvm-project/pull/202634)
- [ ] [DRAFT] [Fuse frequent adjacent SelectionDAG matcher operations](https://github.com/llvm/llvm-project/pull/202635)
- [ ] [DRAFT] [Extend the direct MVT encoding range](https://github.com/llvm/llvm-project/pull/202636)
- [ ] [DRAFT] [Order SelectionDAG operand lists by use frequency](https://github.com/llvm/llvm-project/pull/202637)
- [ ] [DRAFT] [Share repeated terminal SelectionDAG matcher tails](https://github.com/llvm/llvm-project/pull/202638)
- [ ] [DRAFT] [Omit redundant two-child SelectionDAG scope offsets](https://github.com/llvm/llvm-project/pull/202639)
- [ ] [DRAFT] [Encode common integer constants in SelectionDAG matcher opcodes](https://github.com/llvm/llvm-project/pull/202640)
- [ ] [DRAFT] [Compact GlobalISel failure targets in large match tables](https://github.com/llvm/llvm-project/pull/202642)
- [ ] [DRAFT] [Encode GlobalISel root operand indices in match opcodes](https://github.com/llvm/llvm-project/pull/210562)
- [ ] [DRAFT] [Compact generated SDNode descriptions](https://github.com/llvm/llvm-project/pull/202660)
- [ ] [Table-drive fixed SelectionDAG operation names](https://github.com/llvm/llvm-project/pull/202841)
## Clang frontend and diagnostics
- [ ] [DRAFT] [Table-drive ASTContext builtin type initialization](https://github.com/llvm/llvm-project/pull/202622)
- [ ] [DRAFT] [Share attribute pretty-print spellings](https://github.com/llvm/llvm-project/pull/202623)
- [ ] [Deduplicate builtin diagnostic descriptions](https://github.com/llvm/llvm-project/pull/202624)
- [x] [Reuse driver option strings in CompilerInvocation](https://github.com/llvm/llvm-project/pull/202632)
- [x] [Outline constant-interpreter shift diagnostics](https://github.com/llvm/llvm-project/pull/202633)
- [ ] [DRAFT] [Compact OpenCL builtin metadata tables](https://github.com/llvm/llvm-project/pull/202651)
- [ ] [DRAFT] [Share ParsedAttrInfo cross-domain diagnostics](https://github.com/llvm/llvm-project/pull/202654)
- [x] [DRAFT] [Outline LangOptions mismatch diagnostics](https://github.com/llvm/llvm-project/pull/202843)
- [x] [Batch serialized LangOptions values](https://github.com/llvm/llvm-project/pull/202844)
- [x] [Table-drive compiler option dumping](https://github.com/llvm/llvm-project/pull/203161)
- [x] [Batch LangOptions context hashing](https://github.com/llvm/llvm-project/pull/203162)
- [ ] [DRAFT] [Table-drive keyword registration](https://github.com/llvm/llvm-project/pull/203259)
- [ ] [DRAFT] [Share MultiOnDiskHashTable table visitation](https://github.com/llvm/llvm-project/pull/202839)
- [ ] [DRAFT] [Optimize RecursiveASTVisitor instantiations for size](https://github.com/llvm/llvm-project/pull/202657)
- [x] [Inline StmtVisitor fallback methods](https://github.com/llvm/llvm-project/pull/203125)
- [x] [Use DynamicRecursiveASTVisitor for AST listing](https://github.com/llvm/llvm-project/pull/202661)
## Clang tools and analyzers
- [ ] [Share variadic dyn-cast matcher marshalling](https://github.com/llvm/llvm-project/pull/202941)
- [ ] [DRAFT] [Store stateless clang-tidy check factories as function pointers](https://github.com/llvm/llvm-project/pull/202625)
- [x] [Compact the clang-tidy confusable identifier table](https://github.com/llvm/llvm-project/pull/202626)
- [ ] [DRAFT] [Reuse the clang-tidy static initialization cycle visitor](https://github.com/llvm/llvm-project/pull/202627)
- [ ] [DRAFT] [Share clangd semantic highlighting AST traversal code](https://github.com/llvm/llvm-project/pull/202628)
- [ ] [DRAFT] [Share clangd AST traversal in refactoring tweaks](https://github.com/llvm/llvm-project/pull/202629)
- [x] [Use unique_function for clangd config handlers](https://github.com/llvm/llvm-project/pull/203008)
- [x] [Avoid type erasure for local recursive clangd callbacks](https://github.com/llvm/llvm-project/pull/203042)
- [x] [Outline clangd and LLVM Support LSP payload decode errors](https://github.com/llvm/llvm-project/pull/203121)
- [ ] [Store clangd diagnostic names in a direct offset table](https://github.com/llvm/llvm-project/pull/203258)
- [ ] [DRAFT] [Compact Static Analyzer GenericTaint rule descriptors](https://github.com/llvm/llvm-project/pull/202641)
- [x] [Optimize Static Analyzer standard-library summaries for size](https://github.com/llvm/llvm-project/pull/202662)
- [ ] [Reuse clang Tooling standard-library symbol descriptors](https://github.com/llvm/llvm-project/pull/202663)
## LLVM core, options, passes, and analysis
- [ ] ~~[Compact ScopedPrinter EnumEntry string storage](https://github.com/llvm/llvm-project/pull/202631)~~
- [ ] [DRAFT] [Split intrinsic builtin lookup tables](https://github.com/llvm/llvm-project/pull/202644)
- [ ] [DRAFT] [Store intrinsic name lengths in offset entries](https://github.com/llvm/llvm-project/pull/202645)
- [ ] [DRAFT] [Store visibility-specific OptTable help text out of line](https://github.com/llvm/llvm-project/pull/202653)
- [x] [Move the command-line Option constructor out of line](https://github.com/llvm/llvm-project/pull/202847)
- [ ] [DRAFT] [Store generated option strings as offsets](https://github.com/llvm/llvm-project/pull/202783)
- [ ] [DRAFT] [Compact the runtime libcall name lookup table](https://github.com/llvm/llvm-project/pull/202784)
- [ ] [Outline pass pipeline name printing](https://github.com/llvm/llvm-project/pull/202655)
- [x] [Table-drive PassBuilder pass name printing](https://github.com/llvm/llvm-project/pull/202656)
- [ ] [DRAFT] [Compact vector-library descriptors](https://github.com/llvm/llvm-project/pull/202665)
- [ ] [Compile out unused dominator DFS sorting](https://github.com/llvm/llvm-project/pull/202832)
- [ ] [DRAFT] [Share MIR call metadata sorting](https://github.com/llvm/llvm-project/pull/202833)
- [ ] [DRAFT] [Share verifier diagnostic operand rendering](https://github.com/llvm/llvm-project/pull/202845)
- [x] [Compact CodeGen cost table entries](https://github.com/llvm/llvm-project/pull/202836)
## Object and debug information
- [x] [Reuse CodeView enum tables in type dumpers](https://github.com/llvm/llvm-project/pull/202757)
- [ ] [Outline ELF section-content validation errors](https://github.com/llvm/llvm-project/pull/202758)
- [ ] ~~[Share ELF section validation error formatting](https://github.com/llvm/llvm-project/pull/203041)~~
- [ ] [DRAFT] [Store ELF relocation names without pointers](https://github.com/llvm/llvm-project/pull/202798)
- [x] [Avoid std::function in DWARF verifier internals](https://github.com/llvm/llvm-project/pull/202866)
## LLD, OpenMP, and Bazel integration
- [ ] [DRAFT] [Share format-independent LLD ELF garbage-collection work](https://github.com/llvm/llvm-project/pull/202646)
- [ ] [DRAFT] [Parse Visual Studio diagnostics without std::regex](https://github.com/llvm/llvm-project/pull/202789)
- [ ] [DRAFT] [Share LLD ELF dynamic section entry construction](https://github.com/llvm/llvm-project/pull/202831)
- [ ] [DRAFT] [Compact OpenMP runtime function descriptors](https://github.com/llvm/llvm-project/pull/202652)
Contributor guide
Research direction
Start by reviewing the independently listed pull requests, since this issue is a workstream rather than a single code change. The payload names existing LLVM tests, byte-for-byte output comparisons, generated-table reconstruction, and focused performance benchmarks as validation. Done means an independently reviewable patch reduces binary size without removing behavior or harming performance.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 15/100