Low-Compilation-Cost Register Allocation in LLVM-Based Binary Translation
matt_d
68 points
4 comments
April 29, 2026
Related Discussions
Found 5 related stories in 86.3ms across 8,303 title embeddings via pgvector HNSW
- Deterministic Fully-Static Whole-Binary Translation Without Heuristics matt_d · 63 pts · May 13, 2026 · 52% similar
- Retrofitting JIT Compilers into C Interpreters ltratt · 65 pts · April 15, 2026 · 50% similar
- Optimization of 32-bit Unsigned Division by Constants on 64-bit Targets mpweiher · 51 pts · April 12, 2026 · 49% similar
- Want to write a compiler? Just read these two papers (2008) downbad_ · 479 pts · April 15, 2026 · 49% similar
- A complete Llama2 inference engine that fits in 1356 bytes of x86 assembly monax · 26 pts · May 05, 2026 · 47% similar
Discussion Highlights (1 comments)
rurban
It still can be done much cheaper. I just fixed my excessively cheap register allocator for my c compiler rcc. The register allocator is a simple first-fit bitmask with no spilling to stack except for the two predefined spill slots. Only if all 8 registers are in use, it spills the additional registers on the stack. What they call guest registers. No SSA and no BB needed. No crazy mem2reg or graph-coloring. Only once per function. Only for very big functions one register is spilled, usually just rsi. Benchmarks: | Compiler | Compile (ms) | Execute (ms) | Total (ms) | | :------- | -----------: | -----------: | ---------: | | RCC | 61 | 754 | 815 | | TCC | 8 | 628 | 636 | | SLIMCC | 74 | 642 | 716 | | KEFIR | 270 | 765 | 1035 | | GCC0 | 83 | 637 | 720 | | GCCO2 | 204 | 227 | 431 | | CLANG0 | 377 | 620 | 997 | | CLANGO2 | 310 | 221 | 531 |