[llc] Use -filetype=null to disable MIR printing

If you use -stop-after or similar options, llc will normally print MIR.
This patch checks for -filetype=null as a special case to disable MIR
printing. As the comment says, "The Null output is intended for use for
performance analysis ...", and I found this useful for timing a subset
of the passes that llc runs without the significant overhead of printing
MIR just to send it to /dev/null.

Differential Revision: https://reviews.llvm.org/D89476
This commit is contained in:
Jay Foad 2020-10-15 16:45:50 +01:00
parent 7dff6b818b
commit 0c1381d795
2 changed files with 11 additions and 5 deletions

View File

@ -196,11 +196,14 @@ bool LLVMTargetMachine::addPassesToEmitFile(
if (!PassConfig) if (!PassConfig)
return true; return true;
if (!TargetPassConfig::willCompleteCodeGenPipeline()) if (TargetPassConfig::willCompleteCodeGenPipeline()) {
PM.add(createPrintMIRPass(Out)); if (addAsmPrinter(PM, Out, DwoOut, FileType, MMIWP->getMMI().getContext()))
else if (addAsmPrinter(PM, Out, DwoOut, FileType, return true;
MMIWP->getMMI().getContext())) } else {
return true; // MIR printing is redundant with -filetype=null.
if (FileType != CGFT_Null)
PM.add(createPrintMIRPass(Out));
}
PM.add(createFreeMachineFunctionPass()); PM.add(createFreeMachineFunctionPass());
return false; return false;

View File

@ -0,0 +1,3 @@
; -stop-after would normally dump MIR, but with -filetype=null as well check
; there's no output at all.
; RUN: llc -filetype=null -stop-after=finalize-isel -o - %s | count 0