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

Jay Foad via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 15 08:55:40 PDT 2020


foad created this revision.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.
foad requested review of this revision.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89476

Files:
  llvm/lib/CodeGen/LLVMTargetMachine.cpp
  llvm/test/tools/llc/filetype-null-stop-after.ll


Index: llvm/test/tools/llc/filetype-null-stop-after.ll
===================================================================
--- /dev/null
+++ llvm/test/tools/llc/filetype-null-stop-after.ll
@@ -0,0 +1,5 @@
+; RUN: llc -filetype=null -stop-after=finalize-isel -o - %s | FileCheck %s --allow-empty
+
+; -stop-after would normally dump MIR, but with -filetype=null as well check
+; there's no output at all.
+; CHECK-NOT: {{.}}
Index: llvm/lib/CodeGen/LLVMTargetMachine.cpp
===================================================================
--- llvm/lib/CodeGen/LLVMTargetMachine.cpp
+++ llvm/lib/CodeGen/LLVMTargetMachine.cpp
@@ -196,11 +196,15 @@
   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 {
+    // The Null output is intended for use for performance analysis and testing,
+    // not real users.
+    if (FileType != CGFT_Null)
+      PM.add(createPrintMIRPass(Out));
+  }
 
   PM.add(createFreeMachineFunctionPass());
   return false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89476.298397.patch
Type: text/x-patch
Size: 1328 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201015/ab1459aa/attachment.bin>


More information about the llvm-commits mailing list