[PATCH] D64681: Stop IR Dumps occurring after MachineVerifier

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 12 16:53:44 PDT 2019


dsanders created this revision.
Herald added a subscriber: mehdi_amini.
Herald added a project: LLVM.

-print-after-all and -print-before-all print after/before each pass.
Unfortunately this includes the MachineVerifier which doesn't make
any changes or produce any information. The end result is that one of these
options in combination with -verify-machineinstrs cause identical MIR to be
dumped twice for each pass (four times if you use both).

I'm not very familiar with the Pass manager infrastructure but this hack
introduces the concept of a verifier pass which does not trigger additional
IR Dumps.


Repository:
  rL LLVM

https://reviews.llvm.org/D64681

Files:
  include/llvm/Pass.h
  lib/CodeGen/MachineVerifier.cpp
  lib/IR/LegacyPassManager.cpp


Index: lib/IR/LegacyPassManager.cpp
===================================================================
--- lib/IR/LegacyPassManager.cpp
+++ lib/IR/LegacyPassManager.cpp
@@ -784,7 +784,8 @@
     return;
   }
 
-  if (PI && !PI->isAnalysis() && shouldPrintBeforePass(PI->getPassArgument())) {
+  if (!P->isVerifier() && PI && !PI->isAnalysis() &&
+      shouldPrintBeforePass(PI->getPassArgument())) {
     Pass *PP = P->createPrinterPass(
         dbgs(), ("*** IR Dump Before " + P->getPassName() + " ***").str());
     PP->assignPassManager(activeStack, getTopLevelPassManagerType());
@@ -793,7 +794,8 @@
   // Add the requested pass to the best available pass manager.
   P->assignPassManager(activeStack, getTopLevelPassManagerType());
 
-  if (PI && !PI->isAnalysis() && shouldPrintAfterPass(PI->getPassArgument())) {
+  if (!P->isVerifier() && PI && !PI->isAnalysis() &&
+      shouldPrintAfterPass(PI->getPassArgument())) {
     Pass *PP = P->createPrinterPass(
         dbgs(), ("*** IR Dump After " + P->getPassName() + " ***").str());
     PP->assignPassManager(activeStack, getTopLevelPassManagerType());
Index: lib/CodeGen/MachineVerifier.cpp
===================================================================
--- lib/CodeGen/MachineVerifier.cpp
+++ lib/CodeGen/MachineVerifier.cpp
@@ -312,6 +312,8 @@
         report_fatal_error("Found "+Twine(FoundErrors)+" machine code errors.");
       return false;
     }
+
+    bool isVerifier() const override { return true; }
   };
 
 } // end anonymous namespace
Index: include/llvm/Pass.h
===================================================================
--- include/llvm/Pass.h
+++ include/llvm/Pass.h
@@ -214,6 +214,8 @@
 
   template<typename AnalysisType>
   AnalysisType &getAnalysisID(AnalysisID PI, Function &F);
+
+  virtual bool isVerifier() const { return false; }
 };
 
 //===----------------------------------------------------------------------===//


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64681.209643.patch
Type: text/x-patch
Size: 1923 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190712/48636d34/attachment.bin>


More information about the llvm-commits mailing list