Three tiers, one answer: how Wolang keeps its compiler honest
Wolang runs every program three ways: an interpreter that defines the semantics, a fast native tier for development, and an LLVM tier for shipping. If any two disagree, that is a bug, and a differential fuzzer spends its days trying to make them disagree. Here is how that works and the bugs it has found, including one in LLVM itself.

A compiler bug is the worst kind of bug. The program is right, the test is right, and the answer is wrong anyway, so you spend a day doubting your own code before you think to doubt the tool.
Wolang's answer is to never have just one compiler.
The three tiers
Every Wolang program can run three ways:
| Tier | Used by | What it is for |
|---|---|---|
| Interpreter | wolang run --interpret, the debugger |
The reference. It runs the typed IR directly and defines what a program means. |
| Dev tier | wolang run, wolang test |
Our own native code generator for arm64 and x86-64. It compiles fast and has no dependency on LLVM. |
| AOT tier | wolang build |
LLVM, for optimised binaries that need no compiler at run time, including cross-compilation to Windows, Linux, WebAssembly and RISC-V. |
All three start from the same typed SSA IR, so they share the front end, type checking, effects, lowering and the IR verifier. They diverge only where bugs like to live: register allocation, calling conventions, instruction encoding and optimisation.
The rule
If two tiers disagree, it is a bug, even if each answer looks reasonable on its own.
That rule is enforced in three places:
- Every
wolang runalso checks the IR before and after optimisation passes against each other. - Every
wolang testruns each@Testfunction in more than one tier and compares the results. The compiler's 692 unit tests and the libraries' 184 tests all go through this. wolang fuzzgenerates random, well-typed programs and runs them through all three tiers. It finds the miscompilations before a person does.
wolang fuzz --count 200What it has found
A few of the more expensive bugs from the project's history, all caught by tiers disagreeing or by sanitizers running the reference tier:
- The interpreter wrote a
u8as eight bytes. AddressSanitizer found it, and it would have quietly corrupted neighbouring fields. - A nested index
rows[1][2]added the two indices together instead of applying them in turn. <on strings compared pointers instead of contents.- Bringing up the x86-64 tier under emulation turned up nine code generation bugs at once: stack arguments through a trampoline, a missing REX prefix on byte operations, a narrow return value, and others. 94 tests failed before the fixes and none after.
- A bug in LLVM itself. LLVM 23 miscompiles
x != 6 % xin one of its interprocedural passes. Our interpreter and dev tier both said one thing and LLVM said another, so Wolang now pins LLVM 22 until it is fixed upstream.
The last one is the point. With a single compiler you would have filed that as "weird, can't reproduce" and moved on.
Why the interpreter is the reference
It is the simplest of the three and the easiest to read, and every trap (an overflow, an out-of-bounds index, a null) reports its kind and source location. Compiled code reports traps with the same kind, location and message, so a failure looks identical whichever tier hit it.
The interpreter is also what the Debug Adapter Protocol debugger runs on. When you step through Wolang code in VS Code, you are stepping through the semantics the other two tiers are tested against.
What this means if you contribute
If you touch lowering, a back end or the runtime, run the fuzzer with a few seeds before sending the change. And if you ever see wolang run and wolang run --interpret print different things, please open an issue with the program. That is the most valuable kind of report the project gets.
The architecture is described in docs/architecture.md, and the source is on GitHub.