[llvm-commits] CVS: llvm/lib/VMCore/PassManager.cpp
Devang Patel
dpatel at apple.com
Wed Nov 15 11:40:09 PST 2006
Changes in directory llvm/lib/VMCore:
PassManager.cpp updated: 1.31 -> 1.32
---
Log message:
Add run(Function &F) support in FunctionPassManager_New
---
Diffs of the changes: (+41 -6)
PassManager.cpp | 47 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 41 insertions(+), 6 deletions(-)
Index: llvm/lib/VMCore/PassManager.cpp
diff -u llvm/lib/VMCore/PassManager.cpp:1.31 llvm/lib/VMCore/PassManager.cpp:1.32
--- llvm/lib/VMCore/PassManager.cpp:1.31 Tue Nov 14 19:48:14 2006
+++ llvm/lib/VMCore/PassManager.cpp Wed Nov 15 13:39:54 2006
@@ -17,6 +17,7 @@
#include "llvm/ModuleProvider.h"
#include <vector>
#include <map>
+#include <iostream>
using namespace llvm;
@@ -158,6 +159,7 @@
/// track of whether any of the passes modifies the function, and if
/// so, return true.
bool runOnModule(Module &M);
+ bool runOnFunction(Function &F);
/// Return true IFF AnalysisID AID is currently available.
Pass *getAnalysisPassFromManager(AnalysisID AID);
@@ -423,19 +425,31 @@
/// PassManager_X is destroyed, the pass will be destroyed as well, so
/// there is no need to delete the pass. (TODO delete passes.)
/// This implies that all passes MUST be allocated with 'new'.
-void
-FunctionPassManager_New::add(Pass *P) {
+void FunctionPassManager_New::add(Pass *P) {
FPM->add(P);
}
/// Execute all of the passes scheduled for execution. Keep
/// track of whether any of the passes modifies the function, and if
/// so, return true.
-bool
-FunctionPassManager_New::runOnModule(Module &M) {
+bool FunctionPassManager_New::runOnModule(Module &M) {
return FPM->runOnModule(M);
}
+/// run - Execute all of the passes scheduled for execution. Keep
+/// track of whether any of the passes modifies the function, and if
+/// so, return true.
+///
+bool FunctionPassManager_New::run(Function &F) {
+ std::string errstr;
+ if (MP->materializeFunction(&F, &errstr)) {
+ std::cerr << "Error reading bytecode file: " << errstr << "\n";
+ abort();
+ }
+ return FPM->runOnFunction(F);
+}
+
+
/// doInitialization - Run all of the initializers for the function passes.
///
bool FunctionPassManager_New::doInitialization() {
@@ -489,8 +503,7 @@
/// Execute all of the passes scheduled for execution by invoking
/// runOnFunction method. Keep track of whether any of the passes modifies
/// the function, and if so, return true.
-bool
-FunctionPassManagerImpl_New::runOnModule(Module &M) {
+bool FunctionPassManagerImpl_New::runOnModule(Module &M) {
bool Changed = false;
clearAnalysis();
@@ -509,6 +522,28 @@
return Changed;
}
+/// Execute all of the passes scheduled for execution by invoking
+/// runOnFunction method. Keep track of whether any of the passes modifies
+/// the function, and if so, return true.
+bool FunctionPassManagerImpl_New::runOnFunction(Function &F) {
+
+ bool Changed = false;
+ clearAnalysis();
+
+ for (std::vector<Pass *>::iterator itr = passVectorBegin(),
+ e = passVectorEnd(); itr != e; ++itr) {
+ Pass *P = *itr;
+
+ noteDownAvailableAnalysis(P);
+ FunctionPass *FP = dynamic_cast<FunctionPass*>(P);
+ Changed |= FP->runOnFunction(F);
+ removeNotPreservedAnalysis(P);
+ removeDeadPasses(P);
+ }
+ return Changed;
+}
+
+
/// Return true IFF AnalysisID AID is currently available.
Pass *FunctionPassManagerImpl_New::getAnalysisPassFromManager(AnalysisID AID) {
More information about the llvm-commits
mailing list