
Passes that need to traverse the program bottom-up on the call graph (calleesīefore callers).
Make a pass at how to#
Now that you have seen the basics of the mechanics behind passes, we can talkĪbout some more details of how they work and how to use them. That the LLVM emitted by your pass is still valid and well formed LLVM, which Passes listed are automatically inserted by the opt tool to verify Hello: _main Hello: puts Hello: main =-=. $ opt -load lib/LLVMHello.so -hello -time-passes /dev/null Note that everything in this file isĬontained in an anonymous namespace - this reflects the fact that passesĪre self contained units that do not need external interfaces (although they Now that it’s all together, compile the file with a simple “ gmake” commandįrom the top level of your build directory and you should get a new file #include "llvm/Pass.h" #include "llvm/IR/Function.h" #include "llvm/Support/raw_ostream.h" #include "llvm/IR/LegacyPassManager.h" #include "llvm/Transforms/IPO/PassManagerBuilder.h" using namespace llvm namespace ) We start by showing you how to construct a pass, everything from setting up theĬode, to compiling, loading, and executing it. Pass meets (which are indicated by which class they derive from).

Schedules passes to run in an efficient way based on the constraints that your One of the main features of the LLVM Pass Framework is that it Information about what your pass does, and how it can be combined with other On how your pass works, you should inherit from the ModulePass, CallGraphSCCPass, FunctionPass, or LoopPass, or RegionPass classes, which gives the system more Perform the transformations and optimizations that make up the compiler, theyīuild the analysis results that are used by these transformations, and theyĪre, above all, a structuring technique for compiler code.Īll LLVM passes are subclasses of the Pass class, which implementįunctionality by overriding virtual methods inherited from Pass. Passes are where most of the interesting parts of the compiler exist. The LLVM Pass Framework is an important part of the LLVM system, because LLVM Using GDB with dynamically loaded passes.The getAnalysis and getAnalysisIfAvailable methods.Example implementations of getAnalysisUsage.The AnalysisUsage::addRequired and AnalysisUsage::addRequiredTransitive methods.The runOnMachineFunction(MachineFunction &MF) method.The doInitialization(Region *, RGPassManager &) method.The doInitialization(Loop *, LPPassManager &) method.

The doInitialization(CallGraph &) method.
