Skip to content

Commit 2f77922

Browse files
committed
Add explicit doInitialization/doFinalization methods instead of making
the FunctionPassManager redo this for each function. llvm-svn: 30079
1 parent 2f93c0f commit 2f77922

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

llvm/include/llvm/PassManager.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,19 @@ class FunctionPassManager {
7070
///
7171
void add(ImmutablePass *IP);
7272

73+
/// doInitialization - Run all of the initializers for the function passes.
74+
///
75+
bool doInitialization();
76+
7377
/// run - Execute all of the passes scheduled for execution. Keep
7478
/// track of whether any of the passes modifies the function, and if
7579
/// so, return true.
7680
///
7781
bool run(Function &F);
82+
83+
/// doFinalization - Run all of the initializers for the function passes.
84+
///
85+
bool doFinalization();
7886
};
7987

8088
} // End llvm namespace

llvm/lib/VMCore/Pass.cpp

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,26 @@ FunctionPassManager::FunctionPassManager(ModuleProvider *P) :
9494
FunctionPassManager::~FunctionPassManager() { delete PM; }
9595
void FunctionPassManager::add(FunctionPass *P) { PM->add(P); }
9696
void FunctionPassManager::add(ImmutablePass *IP) { PM->add(IP); }
97+
98+
/// doInitialization - Run all of the initializers for the function passes.
99+
///
100+
bool FunctionPassManager::doInitialization() {
101+
return PM->doInitialization(*MP->getModule());
102+
}
103+
97104
bool FunctionPassManager::run(Function &F) {
98105
std::string errstr;
99106
if (MP->materializeFunction(&F, &errstr)) {
100107
std::cerr << "Error reading bytecode file: " << errstr << "\n";
101108
abort();
102109
}
103-
return PM->run(F);
110+
return PM->runOnFunction(F);
111+
}
112+
113+
/// doFinalization - Run all of the initializers for the function passes.
114+
///
115+
bool FunctionPassManager::doFinalization() {
116+
return PM->doFinalization(*MP->getModule());
104117
}
105118

106119

0 commit comments

Comments
 (0)