[llvm-commits] CVS: llvm/include/llvm/CallGraphSCCPass.h Pass.h PassManager.h
Chris Lattner
lattner at cs.uiuc.edu
Sun Sep 19 21:43:00 PDT 2004
Changes in directory llvm/include/llvm:
CallGraphSCCPass.h updated: 1.5 -> 1.6
Pass.h updated: 1.45 -> 1.46
PassManager.h updated: 1.11 -> 1.12
---
Log message:
'Pass' should now not be derived from by clients. Instead, they should derive
from ModulePass. Instead of implementing Pass::run, then should implement
ModulePass::runOnModule.
---
Diffs of the changes: (+28 -13)
Index: llvm/include/llvm/CallGraphSCCPass.h
diff -u llvm/include/llvm/CallGraphSCCPass.h:1.5 llvm/include/llvm/CallGraphSCCPass.h:1.6
--- llvm/include/llvm/CallGraphSCCPass.h:1.5 Tue Apr 20 16:52:07 2004
+++ llvm/include/llvm/CallGraphSCCPass.h Sun Sep 19 23:42:18 2004
@@ -28,7 +28,7 @@
class CallGraphNode;
class CallGraph;
-struct CallGraphSCCPass : public Pass {
+struct CallGraphSCCPass : public ModulePass {
/// doInitialization - This method is called before the SCC's of the program
/// has been processed, allowing the pass to do initialization as necessary.
@@ -52,7 +52,7 @@
/// run - Run this pass, returning true if a modification was made to the
/// module argument. This is implemented in terms of the runOnSCC method.
///
- virtual bool run(Module &M);
+ virtual bool runOnModule(Module &M);
/// getAnalysisUsage - For this class, we declare that we require and preserve
Index: llvm/include/llvm/Pass.h
diff -u llvm/include/llvm/Pass.h:1.45 llvm/include/llvm/Pass.h:1.46
--- llvm/include/llvm/Pass.h:1.45 Tue Aug 24 12:52:35 2004
+++ llvm/include/llvm/Pass.h Sun Sep 19 23:42:18 2004
@@ -84,10 +84,10 @@
///
const PassInfo *getPassInfo() const;
- /// run - Run this pass, returning true if a modification was made to the
+ /// runPass - Run this pass, returning true if a modification was made to the
/// module argument. This should be implemented by all concrete subclasses.
///
- virtual bool run(Module &M) = 0;
+ virtual bool runPass(Module &M) = 0;
/// print - Print out the internal state of the pass. This is called by
/// Analyze to print out the contents of an analysis. Otherwise it is not
@@ -200,13 +200,27 @@
friend class PassManagerT<Module>;
friend class PassManagerT<Function>;
friend class PassManagerT<BasicBlock>;
- virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU);
};
inline std::ostream &operator<<(std::ostream &OS, const Pass &P) {
P.print(OS, 0); return OS;
}
+//===----------------------------------------------------------------------===//
+/// ModulePass class - This class is used to implement unstructured
+/// interprocedural optimizations and analyses. ModulePass's may do anything
+/// they want to the program.
+///
+struct ModulePass : public Pass {
+
+ /// runOnModule - Virtual method overriden by subclasses to process the module
+ /// being operated on.
+ virtual bool runOnModule(Module &M) = 0;
+
+ bool runPass(Module &M) { return runOnModule(M); }
+
+ virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU);
+};
//===----------------------------------------------------------------------===//
@@ -214,7 +228,7 @@
/// not need to be run. This is useful for things like target information and
/// "basic" versions of AnalysisGroups.
///
-struct ImmutablePass : public Pass {
+struct ImmutablePass : public ModulePass {
/// initializePass - This method may be overriden by immutable passes to allow
/// them to perform various initialization actions they require. This is
/// primarily because an ImmutablePass can "require" another ImmutablePass,
@@ -225,14 +239,13 @@
/// ImmutablePasses are never run.
///
- virtual bool run(Module &M) { return false; }
+ virtual bool runOnModule(Module &M) { return false; }
private:
friend class PassManagerT<Module>;
virtual void addToPassManager(PassManagerT<Module> *PM, AnalysisUsage &AU);
};
-
//===----------------------------------------------------------------------===//
/// FunctionPass class - This class is used to implement most global
/// optimizations. Optimizations should subclass this class if they meet the
@@ -242,7 +255,7 @@
/// 2. Optimizing a function does not cause the addition or removal of any
/// functions in the module
///
-struct FunctionPass : public Pass {
+struct FunctionPass : public ModulePass {
/// doInitialization - Virtual method overridden by subclasses to do
/// any necessary per-module initialization.
///
@@ -258,10 +271,11 @@
///
virtual bool doFinalization(Module &M) { return false; }
- /// run - On a module, we run this pass by initializing, ronOnFunction'ing
- /// once for every function in the module, then by finalizing.
+ /// runOnModule - On a module, we run this pass by initializing,
+ /// ronOnFunction'ing once for every function in the module, then by
+ /// finalizing.
///
- virtual bool run(Module &M);
+ virtual bool runOnModule(Module &M);
/// run - On a function, we simply initialize, run the function, then
/// finalize.
@@ -323,7 +337,7 @@
/// To run directly on the basic block, we initialize, runOnBasicBlock, then
/// finalize.
///
- bool run(BasicBlock &BB);
+ bool runPass(BasicBlock &BB);
private:
friend class PassManagerT<Function>;
Index: llvm/include/llvm/PassManager.h
diff -u llvm/include/llvm/PassManager.h:1.11 llvm/include/llvm/PassManager.h:1.12
--- llvm/include/llvm/PassManager.h:1.11 Tue Nov 11 16:41:30 2003
+++ llvm/include/llvm/PassManager.h Sun Sep 19 23:42:19 2004
@@ -20,6 +20,7 @@
namespace llvm {
class Pass;
+class ModulePass;
class Module;
class ModuleProvider;
template<class UnitType> class PassManagerT;
More information about the llvm-commits
mailing list