[llvm-dev] What is the "correct" way to add a print pass in the NPM ?

Jonathan Smith via llvm-dev llvm-dev at lists.llvm.org
Fri Jul 31 07:59:05 PDT 2020


On Fri, Jul 31, 2020 at 9:45 AM Stefanos Baziotis via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
>
> Hi,
>
> I'm interested in the sort of pass where you write `-passes=print<pass-name>` and it calls the `print()` function of the pass.
>
> I have seen some other passes that can invoke `-passes=print<>` but the implementation
> seems to be in the wrapper pass for the old pass manager.
>
> Thanks,
> Stefanos Baziotis
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev

Printing passes in the new pass manager are no different from any
other pass: the 'run()' function is called. Unlike the legacy pass
manager, there is no 'print()' function to be called specifically by
printing passes. You would implement all your printing logic in the
run() function of your pass class. As an example, see
https://www.youtube.com/watch?v=MagR2KY8MQI&t=44m40s (full disclosure:
this is my video). The "print<pass-name>" string in the --passes=...
argument is simply a token registered in PassRegistry.def that maps
that string to a particular pass -- in this case, a printing pass.

Respectfully,
Jon (jvstech)


More information about the llvm-dev mailing list