Skip to content

Commit 0c1381d

Browse files
committed
[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
1 parent 7dff6b8 commit 0c1381d

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

llvm/lib/CodeGen/LLVMTargetMachine.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,11 +196,14 @@ bool LLVMTargetMachine::addPassesToEmitFile(
196196
if (!PassConfig)
197197
return true;
198198

199-
if (!TargetPassConfig::willCompleteCodeGenPipeline())
200-
PM.add(createPrintMIRPass(Out));
201-
else if (addAsmPrinter(PM, Out, DwoOut, FileType,
202-
MMIWP->getMMI().getContext()))
203-
return true;
199+
if (TargetPassConfig::willCompleteCodeGenPipeline()) {
200+
if (addAsmPrinter(PM, Out, DwoOut, FileType, MMIWP->getMMI().getContext()))
201+
return true;
202+
} else {
203+
// MIR printing is redundant with -filetype=null.
204+
if (FileType != CGFT_Null)
205+
PM.add(createPrintMIRPass(Out));
206+
}
204207

205208
PM.add(createFreeMachineFunctionPass());
206209
return false;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
; -stop-after would normally dump MIR, but with -filetype=null as well check
2+
; there's no output at all.
3+
; RUN: llc -filetype=null -stop-after=finalize-isel -o - %s | count 0

0 commit comments

Comments
 (0)