Customizing the default middle-end pipeline
In Chapter 5, you learned how to create your own pass pipeline and manipulate it. Here, we will address a somewhat easier yet equally important use case – how to customize the default pipelines.
What we call the default pipelines are, actually, the sequence of passes that LLVM-based tools such as Clang and opt
invoke when you use the optimization options – O0
, O1
, and so on.
Like in Chapter 5, we have to interact with both the legacy and new pass managers.
For this section, we assume that the middle-end part of the pass pipeline is entirely done with the new pass manager, since this is the reality today in LLVM upstream. However, for the default codegen pipeline, we will focus on the legacy pass manager, since it is still the main vehicle for that.
Concretely, when Clang creates the pass pipeline, it uses one pipeline for the optimization sequence at the LLVM IR level and one pass pipeline to go from LLVM IR...