aboutsummaryrefslogtreecommitdiff
path: root/include/llvm
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2012-11-15 00:14:15 +0000
committerOwen Anderson <resistor@mac.com>2012-11-15 00:14:15 +0000
commit40b6fdb81e12b40dd41c9f9f07befb60ec7291c3 (patch)
tree467a798d5e6f1847a8bb536c5678b1b50f1ed973 /include/llvm
parent3427f0aa7ca6979c8646a9b18c1bdab41dcb6eb0 (diff)
Add doInitialization and doFinalization methods to ModulePass's, to allow them to be re-initialized and reused on multiple Module's.
Patch by Pedro Artigas. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168008 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/Pass.h10
-rw-r--r--include/llvm/PassManager.h8
-rw-r--r--include/llvm/PassManagers.h10
3 files changed, 28 insertions, 0 deletions
diff --git a/include/llvm/Pass.h b/include/llvm/Pass.h
index cd651db1f1..4f701d85ca 100644
--- a/include/llvm/Pass.h
+++ b/include/llvm/Pass.h
@@ -227,10 +227,20 @@ public:
/// createPrinterPass - Get a module printer pass.
Pass *createPrinterPass(raw_ostream &O, const std::string &Banner) const;
+ /// doInitialization - Virtual method overridden by subclasses to do
+ /// any necessary initialization.
+ ///
+ virtual bool doInitialization(void) { return false; }
+
/// runOnModule - Virtual method overriden by subclasses to process the module
/// being operated on.
virtual bool runOnModule(Module &M) = 0;
+ /// doFinalization - Virtual method overriden by subclasses to do any post
+ /// processing needed after all passes have run.
+ ///
+ virtual bool doFinalization(void) { return false; }
+
virtual void assignPassManager(PMStack &PMS,
PassManagerType T);
diff --git a/include/llvm/PassManager.h b/include/llvm/PassManager.h
index ce5fda79f9..1d5e800b4d 100644
--- a/include/llvm/PassManager.h
+++ b/include/llvm/PassManager.h
@@ -58,6 +58,14 @@ public:
/// whether any of the passes modifies the module, and if so, return true.
bool run(Module &M);
+ /// doInitialization - Run all of the initializers for the module passes.
+ ///
+ bool doInitialization();
+
+ /// doFinalization - Run all of the finalizers for the module passes.
+ ///
+ bool doFinalization();
+
private:
/// PassManagerImpl_New is the actual class. PassManager is just the
/// wraper to publish simple pass manager interface
diff --git a/include/llvm/PassManagers.h b/include/llvm/PassManagers.h
index 014df7d30b..b0450f3e00 100644
--- a/include/llvm/PassManagers.h
+++ b/include/llvm/PassManagers.h
@@ -420,10 +420,20 @@ public:
/// cleanup - After running all passes, clean up pass manager cache.
void cleanup();
+ /// doInitialization - Overrides ModulePass doInitialization for global
+ /// initialization tasks
+ ///
+ using ModulePass::doInitialization;
+
/// doInitialization - Run all of the initializers for the function passes.
///
bool doInitialization(Module &M);
+ /// doFinalization - Overrides ModulePass doFinalization for global
+ /// finalization tasks
+ ///
+ using ModulePass::doFinalization;
+
/// doFinalization - Run all of the finalizers for the function passes.
///
bool doFinalization(Module &M);