
LLVM
LLVM is a collection of building blocks used to construct translation programs for programming languages. At its core is an intermediate language that sits between written code and the finished machine instructions.
Programs are written by humans in languages like C++, Rust, or Swift. A processor understands none of that; it only knows its own machine instructions. In between sits a translation program, called a compiler. LLVM is a toolkit from which developers assemble such translation programs. The name was originally an abbreviation, but today it is simply treated as the project’s proper name. LLVM is open source, meaning anyone may read, use, and modify its program code.
Why almost every language today builds on it
In the past, every programming language had to bring its own translation for every type of processor. With five languages and five processor types, that’s twenty-five individual translation paths. Each of these must be maintained and optimized. That is an enormous effort for small language projects.
LLVM splits the problem into two halves. The language only needs to be translated into the LLVM intermediate language. Everything after that is handled by LLVM. Twenty-five paths thus become five plus five, in other words ten. This is precisely why newer languages like Rust and Swift were able to run on so many devices so quickly.
A second reason is the quality of the optimization. LLVM contains hundreds of techniques that make code faster or smaller. This work represents decades of development by Apple, Google, Nvidia, and many others. A single language community could hardly replicate that on its own.
The intermediate language as a shared middle ground
The heart of LLVM is the Intermediate Representation, or IR for short. This is an artificial language that belongs to no real processor. It looks like very simple machine code, but it is readable and identical everywhere. You can think of it as the Esperanto of compilers: a neutral intermediate language that everyone translates into and everyone translates further from.
The process has three stages. At the front is the frontend, which reads the source code of a particular language and produces IR from it. In the middle run the optimization passes, so-called passes. Each pass takes in IR and returns improved IR, for instance by removing unnecessary computations. At the back is the backend, which generates actual instructions for a specific chip from the IR.
A common misconception: LLVM is not a compiler, but the material for building one. The best-known compiler built with it is called Clang, which translates C and C++. Someone who says LLVM often actually means Clang. Also widespread is the confusion with a virtual machine, such as the one Java uses. However, LLVM does not normally execute programs itself; it only generates them.
LLVM in Apple devices, graphics cards, and AI frameworks
Every app on an iPhone was built with a compiler from the LLVM toolkit. Apple has been substantially funding the project since the early 2000s. Android also uses LLVM technology for parts of its system. Even those who never write code use software every day that took this path.
In the AI world, LLVM shows up at a particular point. Models compute on graphics cards, and their compute cores also need machine instructions. Tools like Triton or parts of PyTorch generate this code at runtime and hand it off to LLVM. MLIR, too, a newer project from the same family, is being developed for AI chips.
In the news, the term usually appears indirectly. When a company unveils its own AI chip, one of the first questions is whether an LLVM backend exists for it. Without one, hardly any existing software will run on the new hardware. Compiler support thus helps determine whether a chip stands a chance in the market.