Pass and Pass Manager
LLVM's Pass
infrastructure is one of the many important features of the LLVM system. There are a number of analysis and optimization passes that can be run using this infrastructure. The starting point for LLVM passes is the Pass
class, which is a superclass of all the passes. We need to inherit from some predefined subclasses taking into account what our pass is going to implement.
ModulePass: This is the most general superclass. By inheriting this class we allow the entire module to be analyzed at once. The functions within the module may not be referred to in a particular order. To use it, write a subclass that inherits from the
ModulePass
subclass and overloads therunOnModule
function.Note
Before going ahead with the discussion of other
Pass
classes, let's look into the three virtual methods that thePass
classes override:doInitialization: This is meant to do initialization stuff that does not depend on the current function being processed.
runOn{Passtype}: This...