A full linear scan register allocator, written entirely in Datalog

Linear scan register allocation in Datalog

After building a small linear scan register allocator in Ruby, Max Bernstein wanted to know whether the whole thing could live in Datalog. A conversation with Yannis Smaragdakis at PLDI turned the idea into code: basic blocks and liveness analysis fall out in a handful of rules, while the sequential, imperative steps of linear scan must be simulated declaratively, including a forall emulation for choosing which interval to spill.

Datalog is fun. It's not for everyone or everything. But I love nerd sniping people at conferences.

More from this day

2026-11-26