[llvm] 0c1381d - [llc] Use -filetype=null to disable MIR printing
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 16 09:04:08 PDT 2020
Author: Jay Foad
Date: 2020-10-16T16:51:56+01:00
New Revision: 0c1381d79567f58655561bd39f5efb1d468c930a
URL: https://github.com/llvm/llvm-project/commit/0c1381d79567f58655561bd39f5efb1d468c930a
DIFF: https://github.com/llvm/llvm-project/commit/0c1381d79567f58655561bd39f5efb1d468c930a.diff
LOG: [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
Added:
llvm/test/tools/llc/filetype-null-stop-after.ll
Modified:
llvm/lib/CodeGen/LLVMTargetMachine.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/LLVMTargetMachine.cpp b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
index e94b7ed4de03..6f3deff8cb3b 100644
--- a/llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ b/llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -196,11 +196,14 @@ bool LLVMTargetMachine::addPassesToEmitFile(
if (!PassConfig)
return true;
- if (!TargetPassConfig::willCompleteCodeGenPipeline())
- PM.add(createPrintMIRPass(Out));
- else if (addAsmPrinter(PM, Out, DwoOut, FileType,
- MMIWP->getMMI().getContext()))
- return true;
+ if (TargetPassConfig::willCompleteCodeGenPipeline()) {
+ if (addAsmPrinter(PM, Out, DwoOut, FileType, MMIWP->getMMI().getContext()))
+ return true;
+ } else {
+ // MIR printing is redundant with -filetype=null.
+ if (FileType != CGFT_Null)
+ PM.add(createPrintMIRPass(Out));
+ }
PM.add(createFreeMachineFunctionPass());
return false;
diff --git a/llvm/test/tools/llc/filetype-null-stop-after.ll b/llvm/test/tools/llc/filetype-null-stop-after.ll
new file mode 100644
index 000000000000..5be63a55b648
--- /dev/null
+++ b/llvm/test/tools/llc/filetype-null-stop-after.ll
@@ -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
More information about the llvm-commits
mailing list