Compiler Notes.
From IR to register allocation, from Rust to language servers: plain-spoken posts from inside compilers.
All Posts
Filter by topic.
From Text to Tree: How a Compiler Reads Code
Before a compiler can check or optimize anything, it turns characters into tokens and tokens into a tree. Here is what each step does.
Constant Propagation: Computing Before the Program Runs
If a value can be proven to always be the same constant, the compiler computes it at compile time. What happens when branches get involved?
What Does a Linker Do? Symbols and Relocations
The compiler translates each file on its own; the linker is what combines them into one executable. It does this with symbol tables and relocation records.
What Does Rust's Borrow Checker Actually Check?
Never two paths to the same data where one of them writes. The core rule of the borrow checker is that simple.
SSA Form: One Assignment per Variable
Compilers such as LLVM and GCC turn code into SSA form before analysing it. A small example of why it works so well.
Hoisting Loop-Invariant Code
A computation that gives the same result on every iteration should not stay inside the loop. LICM does that for you.
Editor Support with the Language Server Protocol
Instead of a plugin for every editor, you write one server per language. The protocol boils down to a few JSON messages.
Register Allocation: Fitting into a Few Slots
An IR has unlimited variables, a CPU has a few dozen registers. Register allocation closes that gap.
No posts on this topic yet.