Exploring LLVM
LLVM is a part of the LLVM Project. The LLVM Project hosts compilers and toolchain technologies. The LLVM core is a part of the LLVM Project. The LLVM core is responsible for providing source- and target-independent optimization and for generating code for many CPU architectures. This enables language developers to just create a frontend that generates an LLVM-compatible IR or LLVM IR from the source language.
Did You Know?
LLVM is not an acronym. When the project was started as a research project, it meant Low-Level Virtual Machine. But later, it was decided to use the name as it is rather than as an acronym.
The main advantages of LLVM are as follows:
- LLVM uses a simple low-level language that looks similar to C.
- LLVM is strongly typed.
- LLVM has strictly defined semantics.
- LLVM has accurate and precise garbage collection.
- LLVM provides various optimizations that you can choose based on the requirement. It has aggressive, scalar, inter-procedural, simple-loop, and profile-driven optimizations.
- LLVM provides various compilation models. They are link time, install time, runtime, and offline.
- LLVM generates machine code for various target architectures.
- LLVM provides DWARF debugging information.
Note
DWARF is a debugging file format used by many compilers and debuggers to support source-level debugging. DWARF is architecture-independent and applicable to any processor or operating system. It uses a data structure called a Debugging Information Entry (DIE) to represent each variable, type, procedure, and so on.
If you want to explore more about DWARF, refer to http://dwarfstd.org/doc/Debugging%20using%20DWARF-2012.pdf.
Important Note
LLVM is not a single monolithic project. It is a collection of subprojects and other projects. These projects are used by various languages, such as Ruby, Python, Haskell, Rust, and D, for compilation.
Now that we have an understanding of compilers and LLVM, we will see how it is used.