[llvm-dev] Adding custom callback function before/after passes
Neil Henning via llvm-dev
llvm-dev at lists.llvm.org
Tue Dec 3 09:20:11 PST 2019
If you are using the legacy PassManager and control when the PassManager is
created, you can do this with a little hack like:
struct MyPassManager final : llvm::legacy::PassManager
{
void add(llvm::Pass* const pass) override
{
// Add your own pass which does a before callback
llvm::legacy::PassManager::add(your_start_pass(pass));
// Add the originally requested pass
llvm::legacy::PassManager::add(pass);
// Add your own pass which does an after callback
llvm::legacy::PassManager::add(your_end_pass(pass));
}
} passManager; // add new passes to this pass manager!
I've used this hack in the past (it is also something similar to how opt
lets you bail out on a certain pass).
Cheers,
-Neil.
On Tue, Dec 3, 2019 at 5:02 PM Juneyoung Lee via llvm-dev <
llvm-dev at lists.llvm.org> wrote:
> Hello all,
>
> Is there a way to register callback that runs before/after passes?
> PassTimingInfo seems to do a similar thing by calling
> PassInstrumentationCallbacks::registerBeforePassCallback /
> registerAfterPassCallback, but it is hard-wired with
> StandardInstrumentations class.
> Do we have something similar to RegisterStandardPasses, so custom
> callbacks can be added from somewhere outside LLVM?
>
> Thanks,
> Juneyoung Lee
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
--
Neil Henning
Senior Software Engineer Compiler
unity.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20191203/8fa90895/attachment.html>
More information about the llvm-dev
mailing list