What is the "correct" way to add a print pass in the NPM ?


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.

Stefanos Baziotis

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.

Jon (jvstech)

Ok, got it, thank you!

  • Stefanos

Στις Παρ, 31 Ιουλ 2020 στις 5:59 μ.μ., ο/η Jonathan Smith <jvstech+llvm@gmail.com> έγραψε: