LLVM
In short: LLVM is a construction kit for compilers: many languages translate into the same intermediate representation, and LLVM optimises it and produces machine code for many processors.
In more detail: Instead of building a complete compiler per language and processor, the front end (language) and back end (processor) are separated by the shared LLVM IR.
In Depth
- Structure: Front end (for example Clang for C/C++,
rustcfor Rust, Swift) → LLVM IR → optimisation passes → back end (x86, ARM, RISC-V, WebAssembly, GPU). - IR: A typed, simple intermediate language in SSA form (each variable is assigned once), which eases optimisation.
- Optimisations: Inlining, loop optimisation, vectorisation (SIMD), constant folding.
- By-products: Clang-Tidy, sanitizers (AddressSanitizer), the LLDB debugger.
- Advantage: New languages appear faster, new processors immediately gain many languages.
- Outlook: Alternatives such as GCC remain important, and some languages use their own back ends (Go).
See also: intermediate representation and compiler optimisation