Low-Compilation-Cost Register Allocation in LLVM-Based Binary Translation

matt_d 68 points 4 comments April 29, 2026
dl.acm.org · View on Hacker News

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 |

Semantic search powered by Rivestack pgvector
8,303 stories · 78,303 chunks indexed