Survey of the helper passes
LLVM provides some helper passes that do not directly contribute to the compiler pipeline. These passes are completely optional and do not modify the IR at all. Yet, they are critical for every compiler writer because they allow them to inspect the compiler state (the IR) at various points, by inserting in the pass pipeline the related passes.
In this section, we will cover the two most useful passes:
- The verifier
- The printer
Let us start with the verifier.
The verifier
The core LLVM library (in the IR
directory) features a verifier that checks that the IR is well formed.
For instance, it checks that the definition of a value dominates all its uses so that the IR conforms to the static single assignment (SSA) form or that the input arguments of a fadd
instruction, a floating-point addition, are both of the same type and that this type is of the floating-point family.
This pass is invaluable to narrow down when...