How to invoke the print method in MachineFunctionPass

Hello everyone.

I’m looking for a way how to invoke the ‘print(raw_ostream &OS, const Module*)’ method in MachineFunctionPass. If we have a ‘usual’ pass, which can be used by the ‘opt’ tool, we can just pass the ‘-analyze’ command line argument but what about the ‘llc’ compiler?

As I can see, there is an implementation of the ‘print(raw_ostream &OS, const Module*)’ method in the ‘LiveIntervals.cpp’.

void LiveIntervals::print(raw_ostream &OS, const Module* ) const {
  OS << "********** INTERVALS **********\n";

  // Dump the regunits.

The method also is implemented in 'RegisterCoalescer.cpp' (in fact, this method just invokes one from LiveIntervals).
Is there a way to invoke the 'print' method implemented in **Machine** pass? If so, could you let me know how I can do it?
Thank you.

I suspect you cannot :-/

As far as I understand the code, you would need to put a FunctionPassPrinter into the pass pipeline, and I right now I don’t see any code in llc that would do that. Maybe we should just remove LiveIntervals::print() given that nobody can use it (or someone could implement an -analyze for llc).

In practice this works for me to inspect live intervals (but technically it isn’t using LiveIntervals::print):

$ llc -debug-only=regalloc -run-pass=liveintervals test.mir

  • Matthias

Actually it seems Pass:dump() is calling Pass::print() and the dump() functions is used in a couple places throughout CodeGen for debug printing. So that’s why ::print is implemented at all.

I use it in debugging all the time. I just stick a call LIS->print(...) in the code where I want the intervals to be dumped.



Thank you for the answer. I’ve found the two following call chains: MachineVerifier::report → MachineVerifier::report → LiveIntervals::print
and RegisterCoalescer::print → LiveIntervals::print but I see no invocations of RegisterCoalescer::print). So, the method LiveIntervals::print can be needed for some cases.


чт, 8 нояб. 2018 г. в 4:01, Matthias Braun <>: