diff options
author | Vedant Kumar <vsk@apple.com> | 2018-06-06 19:05:41 +0000 |
---|---|---|
committer | Vedant Kumar <vsk@apple.com> | 2018-06-06 19:05:41 +0000 |
commit | a9e27312b8c0d51ce7c25af764aa0dd50bc696cd (patch) | |
tree | 179f06de0ade1cdad0e0cb64e4ad99c50e5e5735 | |
parent | 0804523bd5b86b4f0e99a7cf733138f63f543388 (diff) | |
download | bcm5719-llvm-a9e27312b8c0d51ce7c25af764aa0dd50bc696cd.tar.gz bcm5719-llvm-a9e27312b8c0d51ce7c25af764aa0dd50bc696cd.zip |
[Debugify] Add a quiet mode to suppress warnings
Suppressing warning output and module dumps significantly speeds up
fuzzing with `opt -debugify-each`.
llvm-svn: 334117
-rw-r--r-- | llvm/test/DebugInfo/debugify-each.ll | 3 | ||||
-rw-r--r-- | llvm/tools/opt/Debugify.cpp | 31 |
2 files changed, 19 insertions, 15 deletions
diff --git a/llvm/test/DebugInfo/debugify-each.ll b/llvm/test/DebugInfo/debugify-each.ll index 8d5eb46361e..e290b948cc7 100644 --- a/llvm/test/DebugInfo/debugify-each.ll +++ b/llvm/test/DebugInfo/debugify-each.ll @@ -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 - | \ diff --git a/llvm/tools/opt/Debugify.cpp b/llvm/tools/opt/Debugify.cpp index f12eabfa895..5ed3de3622b 100644 --- a/llvm/tools/opt/Debugify.cpp +++ b/llvm/tools/opt/Debugify.cpp @@ -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) { |