HeadlinesBriefing favicon HeadlinesBriefing.com

Tiny compiler back end delivers 70% performance

Hacker News •
×

The open‑source project QBE provides a tiny compiler back end that claims roughly 70% of the performance of heavyweight optimizing compilers while staying under 10% of their code size. Written in C, the codebase deliberately remains hobby‑scale, making it easy to hack and extend. Its compactness forces a focus on high‑impact optimizations for real‑world workloads.

QBE’s design embraces the full C ABI, letting programs compiled with it call native C functions and vice‑versa without extra glue. The intermediate language is a uniform SSA form used throughout every stage, enabling cheap copy elimination, sparse conditional constant propagation, and dead‑code removal. Target triples include amd64, arm64 and riscv64, covering most modern desktops and servers.

Despite its modest footprint, QBE delivers surprisingly fast compile times—around two seconds on a Core 2 Duo with -O2 flags. Its register allocator sidesteps traditional graph‑coloring by splitting spilling and allocation phases, using SSA‑based heuristics and loop analysis to choose spill locations. Linear allocation with hinting further trims overhead, making it attractive for rapid prototyping in early.

Developers can experiment by writing QBE’s own SSA syntax, as the project’s README shows a self‑contained example that defines a simple add function and calls a variadic printf from libc. Building the example requires only the qbe tool and a standard C compiler, then linking against the system library. The community stays active on a mailing list and IRC channel for patches and discussion.