[PATCH] D46941: [Debugify] Print errors and warnings to stderr

Anastasis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 16 06:34:06 PDT 2018


gramanas created this revision.
gramanas added a reviewer: vsk.
Herald added a subscriber: llvm-commits.

Currently debugify clutters the terminal with it's output.
With this patch the errors and warnings generated go to stderr.

The PASS or FAIL still ends up in stdout.

A followup patch will dump the errors/warnings and the generated IR with the problem to a file,
so that debugify won't break piping opt's output to other tools.


Repository:
  rL LLVM

https://reviews.llvm.org/D46941

Files:
  test/DebugInfo/debugify.ll
  tools/opt/Debugify.cpp


Index: tools/opt/Debugify.cpp
===================================================================
--- tools/opt/Debugify.cpp
+++ tools/opt/Debugify.cpp
@@ -163,10 +163,10 @@
         continue;
       }
 
-      outs() << "ERROR: Instruction with empty DebugLoc in function ";
-      outs() << F.getName() << " --";
-      I.print(outs());
-      outs() << "\n";
+      errs() << "ERROR: Instruction with empty DebugLoc in function ";
+      errs() << F.getName() << " --";
+      I.print(errs());
+      errs() << "\n";
       HasErrors = true;
     }
 
@@ -185,17 +185,17 @@
 
   // Print the results.
   for (unsigned Idx : MissingLines.set_bits())
-    outs() << "WARNING: Missing line " << Idx + 1 << "\n";
+    errs() << "WARNING: Missing line " << Idx + 1 << "\n";
 
   for (unsigned Idx : MissingVars.set_bits())
-    outs() << "ERROR: Missing variable " << Idx + 1 << "\n";
+    errs() << "ERROR: Missing variable " << Idx + 1 << "\n";
   HasErrors |= MissingVars.count() > 0;
 
   outs() << Banner << " [" << NameOfWrappedPass << "]: "
          << (HasErrors ? "FAIL" : "PASS") << '\n';
   if (HasErrors) {
-    outs() << "Module IR Dump\n";
-    M.print(outs(), nullptr, false);
+    errs() << "Module IR Dump\n";
+    M.print(errs(), nullptr, false);
   }
 
   // Strip the Debugify Metadata if required.
Index: test/DebugInfo/debugify.ll
===================================================================
--- test/DebugInfo/debugify.ll
+++ test/DebugInfo/debugify.ll
@@ -13,10 +13,10 @@
 ; RUN: opt -enable-debugify -passes=verify -S -o - < %s | \
 ; RUN:   FileCheck %s -implicit-check-not="CheckModuleDebugify: FAIL"
 
-; RUN: opt -debugify -strip -check-debugify -S -o - < %s | \
+; RUN: opt -debugify -strip -check-debugify -S -o - < %s 2>&1 | \
 ; RUN:   FileCheck %s -check-prefix=CHECK-FAIL
 
-; RUN: opt -enable-debugify -strip -S -o - < %s | \
+; RUN: opt -enable-debugify -strip -S -o - < %s 2>&1 | \
 ; RUN:   FileCheck %s -check-prefix=CHECK-FAIL
 
 ; RUN: opt -enable-debugify -S -o - < %s | FileCheck %s -check-prefix=PASS


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46941.147072.patch
Type: text/x-patch
Size: 2051 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180516/5521d038/attachment.bin>


More information about the llvm-commits mailing list