The logging capabilities in LLVM
One of the nice things that you get for almost free when building components with the LLVM infrastructure is its logging capabilities.
You can use this feature as soon as you’ve hooked up the LLVM command-line interface (CLI) in your compiler (see Chapter 5 on how to do this). The opt
developer tool, which you can build within the LLVM project and Clang, is set up to expose these logging capabilities.
Let’s start with the first class of logging that you can enable: intermediate dumps.
Printing the IR between passes
The pass managers expose command-line options to print the IR before and after each pass using the textual representation. You can use the following options to enable this printing:
print-before-all
/print-after-all
: Print the IR before (or after, respectively) each pass in the current pipeline.print-before
/print-after=PassName1[,PassName2]*
: Print the IR before (or after, respectively)PassName1...