IT lexicon › Programming › GHC calling convention

GHC calling convention

Programming På svenska → Updated: 2026-11-06

An LLVM calling convention that exists so a single compiler, Haskell's GHC, can use LLVM as a backend.

GHC compiles to an abstract machine, the STG machine, with its own virtual registers: a stack pointer, a heap pointer and argument registers R1 through R6. GHC's native code generator pins these to specific machine registers, and all generated code relies on that. When David Terei built the LLVM backend around 2010, no existing convention could express it, so LLVM got a new one: cc 10, also known as ghccc.

Under it every argument travels in a register that mirrors an STG register, and no register is callee-saved at all. Haskell code rarely returns in the usual sense; it jumps onward with tail calls, so there is nothing to preserve. Erlang's HiPE got cc 11 for similar reasons. A private slot in LLVM's convention table, it turns out, is what a sufficiently determined user gets.

← Back to the lexicon