Until now, a new pass was a dynamic object that was run independently. The opt tool consists of a pipeline of such passes that are registered with the pass manager, and a part of LLVM. Let's see how to register our pass with the Pass Manager.
The PassManager
class takes a list of passes, ensures that their prerequisites are set up correctly, and then schedules the passes to run efficiently. The Pass Manager does two main tasks to try to reduce the execution time of a series of passes:
Shares the analysis results to avoid recomputing analysis results as much as possible
Pipelines the execution of passes to the program to get better cache and memory usage behavior out of a series of passes by pipelining the passes together