The LLVM Compiler Framework and Infrastructure Tutorial

The LLVM Compiler Infrastructure (http://llvm.cs. uiuc.edu) is a robust system that is well suited for a wide variety of research and development work. This brief paper introduces the LLVM system and provides pointers to more extensive documentation, complementing the tutorial presented at LCPC. 1 Brief Overview and Goals The LLVM Compiler Infrastructure  is a language and target-independent compiler system, designed for both static and dynamic compilation. LLVM (Low Level Virtual Machine) can be used to build both traditional optimizing compilers for high performance programming languages as well as compiler-based tools such as Just-In-Time (JIT) translators, profilers, binary translators, memory sandboxing tools, static analysis tools, and others. A major goal of the LLVM development community is to provide a fast, robust, and well-documented core framework to support high-quality compilers and tools. A second major goal is to develop a broad community of contributors to ensure that the software continues to grow and be relevant, and to maintain its robustness and quality. A third goal is to provide a flexible infrastructure for new compiler development and research. 2 Key LLVM Design Features The LLVM system has three main components: the LLVM Virtual Instruction Set, a collection of reusable libraries for analysis, transformation and code generation; and tools built from these libraries. The LLVM framework is characterized by a clean, simple, and modular design, which allows new users to understand the representation, write new analyses, transformations, and tools easily. The LLVM Virtual Instruction Set is the common intermediate representation shared by all of the LLVM subsystems. It is a simple, mid-level, threeaddress code representation that is designed to be both language-independent and target-independent . The instruction set provides explicit control-flow graphs, explicit dataflow information (in SSA form), and a mid-level, language R. Eigenmann et al. . The key design features and the innovative aspects of the code representation are are described in a paper , and the complete instruction set is described in an online reference manual . The LLVM source base mostly consists of modular and reusable libraries. These components include analyses and optimizations, native code generators, JIT compiler support, profile-guided feedback, etc. These compiler components reduce the cost and difficulty of building compilers for new platforms, new source languages, and for building new kinds of tools (debuggers, profilers, etc). The LLVM system also includes several complete tools built from these components, including an ANSI-conforming C/C++ compiler (which uses the GNU Compiler Collection (GCC) parsers). The C/C++ compiler applies a large number of module-level (compile-time) and cross-module (link-time) optimizations. Other LLVM tools include programs to manipulate the IR (e.g. convert between ASCII and binary formats, extract functions from a program, etc), a modular optimizer (which can run any LLVM optimization on an program, driven from the command line), automated compiler debugging tools, and others.