[llvm-dev] Having a ModulePass to schedule other Function/ModulePasses
Joseph via llvm-dev
llvm-dev at lists.llvm.org
Mon Aug 31 02:27:41 PDT 2020
I’d like to have an initialization and finalization step for a bunch of
custom out-of-tree Function/ModulePasses. I was thinking of having a single
ModulePass (call it Scheduler) that would take care of that:
// Pseudocode
struct Scheduler: ModulePass {
runOnModule(Module module) {
if (!is_relevant(module)) {
// Skip non-relevant modules
return true;
}
function_pass_1 = create_function_pass_1()
function_pass_1.doInitialization(module);
for (auto func: module.getFunctionList()) {
function_pass_1.runOnFunction(func);
}
function_pass_2 = create_function_pass_2()
function_pass_2.doInitialization(module);
for (auto func: module.getFunctionList()) {
function_pass_2.runOnFunction(func);
}
function_pass_3 = create_function_pass_3()
function_pass_3.doInitialization(module);
for (auto func: module.getFunctionList()) {
function_pass_3.runOnFunction(func);
}
Error err = run_diagnostics(module);
if (err) {
// Something bad happened
return false;
}
}
}
As you can see, some initialization and finalization relevant to specific
passes is relevant here.
My question is: did LLVM solve this problem already (maybe using
PassDependencies? Do they work for out-of-tree passes?)? Are there any
clear drawbacks to using this approach?
Many thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200831/d4179d8c/attachment.html>
More information about the llvm-dev
mailing list