Technical requirements
The tools we'll need in this chapter are the opt
command-line utility and clang
. Please build them using the following command:
$ ninja opt clang
Most of the code in this chapter can be implemented inside LLVM pass – and the pass plugin – as introduced in Chapter 9, Working with PassManager and AnalysisManager.
In addition, please install the Graphviz tool. You can consult the following page for an installation guide for your system: https://graphviz.org/download. On Ubuntu, for instance, you can install that package via the following command:
$ sudo apt install graphviz
We will use a command-line tool – the dot
command – provided by Graphviz to visualize the control flow of a function.
The code example mentioned in this chapter can be implemented inside LLVM pass, if not specified otherwise.