From f627892e26002025396d2d09bc593e42eee56a24 Mon Sep 17 00:00:00 2001
From: Chris Lattner
@@ -89,7 +89,7 @@
All LLVM passes are subclasses of the Pass class, which implement functionality by overriding virtual methods inherited -from Pass. Depending on how your pass works, you may be able to -inherit from the CallGraphSCCPass, -FunctionPass, or Pass. Depending on how your pass works, you should inherit from +the ModulePass, CallGraphSCCPass, FunctionPass, or BasicBlockPass classes, which gives the system more information about what your pass does, and how it can be combined with other passes. One of the main features of the LLVM Pass Framework is that it @@ -435,37 +436,38 @@ invalidated, and are never "run".
The "Pass" +href="http://llvm.cs.uiuc.edu/doxygen/classllvm_1_1ModulePass.html">ModulePass" class is the most general of all superclasses that you can use. Deriving from -Pass indicates that your pass uses the entire program as a unit, +ModulePass indicates that your pass uses the entire program as a unit, refering to function bodies in no predictable order, or adding and removing -functions. Because nothing is known about the behavior of direct Pass +functions. Because nothing is known about the behavior of ModulePass subclasses, no optimization can be done for their execution.
-To write a correct Pass subclass, derive from Pass and -overload the run method with the following signature:
+To write a correct ModulePass subclass, derive from +ModulePass and overload the runOnModule method with the +following signature:
- virtual bool run(Module &M) = 0; + virtual bool runOnModule(Module &M) = 0;-
The run method performs the interesting work of the pass, and should -return true if the module was modified by the transformation, false +
The runOnModule method performs the interesting work of the pass, +and should return true if the module was modified by the transformation, false otherwise.
In contrast to direct Pass subclasses, direct In contrast to ModulePass subclasses, FunctionPass subclasses do have a predictable, local behavior that can be expected by the system. All FunctionPass execute on each function in the program @@ -1538,23 +1540,24 @@ Despite that, we have kept the LLVM passes SMP ready, and you should too.
Currently it is illegal for a Pass to require a -FunctionPass. This is because there is -only one instance of the FunctionPass -object ever created, thus nowhere to store information for all of the functions -in the program at the same time. Although this has come up a couple of times -before, this has always been worked around by factoring one big complicated pass -into a global and an interprocedural part, both of which are distinct. In the -future, it would be nice to have this though.
+Currently it is illegal for a ModulePass +to require a FunctionPass. This is because +there is only one instance of the FunctionPass object ever created, thus nowhere +to store information for all of the functions in the program at the same time. +Although this has come up a couple of times before, this has always been worked +around by factoring one big complicated pass into a global and an +interprocedural part, both of which are distinct. In the future, it would be +nice to have this though.
Note that it is no problem for a FunctionPass to require the results of a Pass, only the other way around.
+href="#ModulePass">ModulePass, only the other way around.