IT lexicon › Programming › Linear scan register allocation

Linear scan register allocation

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

A register allocator that sorts live intervals and hands out registers in a single sweep, instead of building and colouring a graph.

Massimiliano Poletto and Vivek Sarkar described it in 1999 with a clear target in mind: JIT compilers can't afford graph colouring. The algorithm walks the intervals in order of start point, keeping a list of those currently active. When registers run out it spills the interval that lives furthest into the future — the same idea as optimal cache eviction, and just as easy to explain on a whiteboard.

The generated code is somewhat worse than with a graph-colouring allocator, but allocation runs in close to linear time. Java HotSpot's client compiler adopted a variant with interval splitting in 2005, and LLVM used linear scan until 2011, when a greedy allocator that splits more aggressively replaced it. It lives on in JITs, where every millisecond spent compiling is a millisecond the user spends waiting.

← Back to the lexicon