[llvm] r334117 - [Debugify] Add a quiet mode to suppress warnings

Vedant Kumar via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 6 12:05:41 PDT 2018


Author: vedantk
Date: Wed Jun  6 12:05:41 2018
New Revision: 334117

URL: http://llvm.org/viewvc/llvm-project?rev=334117&view=rev
Log:
[Debugify] Add a quiet mode to suppress warnings

Suppressing warning output and module dumps significantly speeds up
fuzzing with `opt -debugify-each`.

Modified:
    llvm/trunk/test/DebugInfo/debugify-each.ll
    llvm/trunk/tools/opt/Debugify.cpp

Modified: llvm/trunk/test/DebugInfo/debugify-each.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/debugify-each.ll?rev=334117&r1=334116&r2=334117&view=diff
==============================================================================
--- llvm/trunk/test/DebugInfo/debugify-each.ll (original)
+++ llvm/trunk/test/DebugInfo/debugify-each.ll Wed Jun  6 12:05:41 2018
@@ -13,6 +13,9 @@
 ; Verify that debugify each can be safely used with piping
 ; RUN: opt -debugify-each -O1 < %s | opt -O2 -o /dev/null
 
+; Check that the quiet mode emits no messages.
+; RUN: opt -disable-output -debugify-quiet -debugify-each -O1 < %s 2>&1 | count 0
+
 ; Check that stripped textual IR compares equal before and after applying
 ; debugify.
 ; RUN: opt -O1 < %s -S -o - | \

Modified: llvm/trunk/tools/opt/Debugify.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/Debugify.cpp?rev=334117&r1=334116&r2=334117&view=diff
==============================================================================
--- llvm/trunk/tools/opt/Debugify.cpp (original)
+++ llvm/trunk/tools/opt/Debugify.cpp Wed Jun  6 12:05:41 2018
@@ -35,6 +35,11 @@ using namespace llvm;
 
 namespace {
 
+cl::opt<bool> Quiet("debugify-quiet",
+                    cl::desc("Suppress verbose debugify output"));
+
+raw_ostream &dbg() { return Quiet ? nulls() : errs(); }
+
 bool isFunctionSkipped(Function &F) {
   return F.isDeclaration() || !F.hasExactDefinition();
 }
@@ -57,7 +62,7 @@ bool applyDebugifyMetadata(Module &M,
                            StringRef Banner) {
   // Skip modules with debug info.
   if (M.getNamedMetadata("llvm.dbg.cu")) {
-    errs() << Banner << "Skipping module with debug info\n";
+    dbg() << Banner << "Skipping module with debug info\n";
     return false;
   }
 
@@ -159,7 +164,7 @@ bool checkDebugifyMetadata(Module &M,
   // Skip modules without debugify metadata.
   NamedMDNode *NMD = M.getNamedMetadata("llvm.debugify");
   if (!NMD) {
-    errs() << Banner << "Skipping module without debugify metadata\n";
+    dbg() << Banner << "Skipping module without debugify metadata\n";
     return false;
   }
 
@@ -190,10 +195,10 @@ bool checkDebugifyMetadata(Module &M,
         continue;
       }
 
-      errs() << "ERROR: Instruction with empty DebugLoc in function ";
-      errs() << F.getName() << " --";
-      I.print(errs());
-      errs() << "\n";
+      dbg() << "ERROR: Instruction with empty DebugLoc in function ";
+      dbg() << F.getName() << " --";
+      I.print(dbg());
+      dbg() << "\n";
       HasErrors = true;
     }
 
@@ -212,20 +217,16 @@ bool checkDebugifyMetadata(Module &M,
 
   // Print the results.
   for (unsigned Idx : MissingLines.set_bits())
-    errs() << "WARNING: Missing line " << Idx + 1 << "\n";
+    dbg() << "WARNING: Missing line " << Idx + 1 << "\n";
 
   for (unsigned Idx : MissingVars.set_bits())
-    errs() << "ERROR: Missing variable " << Idx + 1 << "\n";
+    dbg() << "ERROR: Missing variable " << Idx + 1 << "\n";
   HasErrors |= MissingVars.count() > 0;
 
-  errs() << Banner;
+  dbg() << Banner;
   if (!NameOfWrappedPass.empty())
-    errs() << " [" << NameOfWrappedPass << "]";
-  errs() << ": " << (HasErrors ? "FAIL" : "PASS") << '\n';
-  if (HasErrors) {
-    errs() << "Module IR Dump\n";
-    M.print(errs(), nullptr, false);
-  }
+    dbg() << " [" << NameOfWrappedPass << "]";
+  dbg() << ": " << (HasErrors ? "FAIL" : "PASS") << '\n';
 
   // Strip the Debugify Metadata if required.
   if (Strip) {




More information about the llvm-commits mailing list