Marmot Builds a Go Compiler on MLIR and LLVM
Marmot is an experimental Go compiler built on MLIR and LLVM that keeps Go code and go.mod unchanged while replacing only code generation, producing small, fast native binaries and errors that point to the fix. It reuses Go's type checker, SSA builder and standard library, and uses a custom go dialect to preserve Go semantics in MLIR long enough to eliminate bounds checks, keep objects on the stack and call interface methods directly. It already compiles real Go programs including itself, but is explicitly not production-ready.
Full Report
Contents5 sections
Go, lowered to machine code
marmot is a Go compiler built on MLIR and LLVM. Keep your Go code and your go.mod, switch the compiler, and get small, fast native binaries and errors that show you the fix.
Get startedRead the benchmarksSee the progress
Experimental: marmot compiles real Go programs, including itself, and checks every test program against Go, but it is not ready for production.
-
Go
Your code, unchanged.
var s int32
for _, x := range xs {
s += x
}
return s-
MLIR, with the go dialect
Still Go: an index into a slice, with its bounds check.
%v9 = llvm.extractvalue %a0[0] : !llvm.struct<(ptr, i64, i64)>
%v10 = llvm.extractvalue %a0[1] : !llvm.struct<(ptr, i64, i64)>
%v11 = go.index %v9[%v7] len %v10, i32 : i64
%v12 = llvm.load %v11 {alignment = 4 : i64, go.unsafe} : !llvm.ptr -> i32
%v13 = llvm.add %v1, %v12 : i32-
LLVM IR
The check is gone; four int32 values at a time.
%wide.load = load <4 x i32>, ptr %5, align 4
%wide.load12 = load <4 x i32>, ptr %6, align 4
%wide.load13 = load <4 x i32>, ptr %7, align 4
%wide.load14 = load <4 x i32>, ptr %8, align 4
%9 = add <4 x i32> %wide.load, %vec.phi-
arm64 machine code
Two 128 bit loads, four vector adds.
ldp q4, q5, [x8, #-0x20]
ldp q6, q7, [x8], #0x40
add.4s v0, v4, v0
add.4s v1, v5, v1
add.4s v2, v6, v2
add.4s v3, v7, v3Against go build
Measured on an Apple M3 Pro, newest measurement of each. Every program’s output is checked against Go. Shorter bars are better.
| Measurement | marmot | go | To scale |
|---|---|---|---|
| hello world with println, ‑releasebinary size | 201 KB | 1.83 MB | |
| hello world with fmt.Println, ‑releasebinary size | 698 KB | 2.43 MB | |
| run time, 45 programs, ‑releasegeometric mean; 37 faster than Go, 8 slower | 1.54x faster | 1x | |
| first build of cmd/marmot, empty caches325 packages, 2026-11-14 | 4.40 to 4.57 s | 6.14 to 6.18 s | |
| rebuild, nothing changed325 packages, 2026-11-14 | 0.05 s | 0.15 s | |
| one line edit, leaf package325 packages, 2026-11-14 | 0.59 s | 0.66 to 0.68 s | |
| one line edit, deep package325 packages, 2026-11-14 | 0.72 to 0.76 s | 1.18 to 1.23 s |
- hello world with println, ‑releasebinary sizemarmot201 KBgo1.83 MB
- hello world with fmt.Println, ‑releasebinary sizemarmot698 KBgo2.43 MB
- run time, 45 programs, ‑releasegeometric mean; 37 faster than Go, 8 slowermarmot1.54x fastergo1x
- first build of cmd/marmot, empty caches325 packages, 2026-11-14marmot4.40 to 4.57 sgo6.14 to 6.18 s
- rebuild, nothing changed325 packages, 2026-11-14marmot0.05 sgo0.15 s
- one line edit, leaf package325 packages, 2026-11-14marmot0.59 sgo0.66 to 0.68 s
- one line edit, deep package325 packages, 2026-11-14marmot0.72 to 0.76 sgo1.18 to 1.23 s
Every number and how it was measured
Errors that show the fix
Marmots stand guard and whistle when something is wrong. marmot’s errors show the source, mark the exact span, label every place involved, and suggest a fix that marmot fix can apply.
Off a terminal they are the plain lines the go tool prints. Under a coding agent they are JSON, with the spans, the source around them and the fixes as edits. Every error has a stable code, and all 44 are explained.
shapes

shapes

One command for the whole loop
marmot works like the go command, and does what people usually install next to it.
buildCompile a program. Dev builds for fast rebuilds, -release for whole program optimization.runCompile and run a program.testRun package tests like go test, with each failure shown at its line.checkRun vet, lint, gopls, vuln, tidy, cross builds and more in one cached pass.fixApply the suggested fixes of errors and findings, and keep only what still builds.fmtFormat source and fix imports, as gofmt and goimports do.watchBuild, run or test again after every save.replEvaluate Go expressions and statements as you type.benchRun benchmarks against go test and report which changes are significant.profRead a pprof profile in the terminal, as a tree or line by line.sizeShow what a binary is made of, and why a function is in it.generateRun go directives, restoring cached outputs.explainDescribe an error code, with the mistake and the fix.doctorCheck the installation and say what to fix.mcpServe build, run, test, fix and explain to coding agents.
Go’s front end, MLIR and LLVM behind it
marmot keeps the parts of the Go toolchain that define the language: the type checker, the SSA builder and Go’s own standard library. It replaces the parts that generate code. A small go dialect keeps Go’s meaning in MLIR long enough to remove bounds checks, keep objects on the stack and call interface methods directly.