Details
- Reviewers
philip.pfaffe fedor.sergeev chandlerc
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 34354 Build 34353: arc lint + arc unit
Event Timeline
I'm not familiar with MIR printing usecases, and there are no tests for MIR printer.
Yet if MIR printing pass is to be applied to the Module only then there is no need to make it a MachineFunction pass, just do everything in a single run(Module...) method.
I would expect to see a registration of this pass in PassRegistry.def as a module pass. Perhaps named as print-mir?
Also, this patch should definitely have some dependencies on prior work introducing MachineFunction as IRUnit etc...
llvm/lib/CodeGen/MIRPrintingPass.cpp | ||
---|---|---|
27–31 | This looks as something artificial. |
I took the liberty of setting a parent revision, hopefully thats what you did intend to do...
I'm not so clear on the use case of the MIR printing pass either, but for sure, llc uses it. To be safe, I just followed how the legacy pass manager did things to try and keep the original intent the same. For example, I did not register the pass in the pass registry, because it is not actually part of the created pass pipeline in the legacy pass manager in llc. There is no way to specify print-mir as part of -run-pass, perhaps because it is already triggered by other command flags. So since MIR printing is done separately in llc, I have followed that convention and done the same in my llc patch.
llvm/lib/CodeGen/MIRPrintingPass.cpp | ||
---|---|---|
27–31 | In the legacy pass manager, printing MIR functions is done exactly this way. I suspect the reason is that MIR printing for individual MachineFunctions is needed for debugging. Another reason I followed the design of the legacy pass manager is that it is quite a lot of boiler plate and analysis querying just to iterate over every function of a module, and then querying MachineModuleInfo to get the MachineFunction out of each Function. In fact, since the adaptors abstract exactly that, I followed the established precedent. Perhaps we could abstract the idea of iterating over the machine functions of a module some other way? |
The MIRPrinter is used to print MIR when used with -stop-before / -stop-after / -run-pass flags in llc (see https://llvm.org/docs/MIRLangRef.html#mir-testing-guide).
In the case of -stop-*, LLVMTargetMachine.cpp:addPassesToEmitFile sets it up.
In the case of -run-pass, llc.cpp:compileModule does (if (!RunPassNames->empty()) { ...).
As for tests, basically all .mir tests that use the flags above use it.
Filename is .h not .cpp; also, needs a 'C++' tag.