IT lexicon › Programming › Greedy register allocator

Greedy register allocator

Programming På svenska → Updated: 2026-11-06

LLVM's default register allocator since 2011: it serves the most important live ranges first and splits or evicts everything else.

LLVM long relied on a variant of linear scan, which walks the code in order and spills when it runs out of registers. Jakob Stoklund Olesen replaced it in LLVM 3.0 with an allocator that works in priority order instead. Large, heavily used live ranges pick registers first. If a newcomer collides with one already placed, it may evict it, provided it matters more.

A range left without a register isn't spilled straight away. The allocator first tries to split it around loops and other hot spots, so only the cold part ends up on the stack. Spilling is the last resort, and even then rematerialisation can sometimes avoid touching memory at all. The result isn't optimal, but it is fast to compute and rarely stupid.

← Back to the lexicon