IR: Skip -print-*-all after -print-*
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 11 Jul 2018 23:30:25 +0000 (23:30 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 11 Jul 2018 23:30:25 +0000 (23:30 +0000)
This changes `-print-*` from transformation passes to analysis passes so
that `-print-after-all` and `-print-before-all` don't trigger.  This
avoids some redundant output.

Patch by Son Tuan Vu!

llvm-svn: 336869

llvm/lib/IR/IRPrintingPasses.cpp
llvm/test/Other/printer.ll [new file with mode: 0644]

index 2aff2f2ebe43a99585417d5a7b53d50e3b83a8df..befe1d9ffb1cda24d0e7f98f55932fdb3a639d88 100644 (file)
@@ -127,13 +127,13 @@ public:
 
 char PrintModulePassWrapper::ID = 0;
 INITIALIZE_PASS(PrintModulePassWrapper, "print-module",
-                "Print module to stderr", false, false)
+                "Print module to stderr", false, true)
 char PrintFunctionPassWrapper::ID = 0;
 INITIALIZE_PASS(PrintFunctionPassWrapper, "print-function",
-                "Print function to stderr", false, false)
+                "Print function to stderr", false, true)
 char PrintBasicBlockPass::ID = 0;
 INITIALIZE_PASS(PrintBasicBlockPass, "print-bb", "Print BB to stderr", false,
-                false)
+                true)
 
 ModulePass *llvm::createPrintModulePass(llvm::raw_ostream &OS,
                                         const std::string &Banner,
diff --git a/llvm/test/Other/printer.ll b/llvm/test/Other/printer.ll
new file mode 100644 (file)
index 0000000..ac1abd7
--- /dev/null
@@ -0,0 +1,13 @@
+; RUN: opt -mem2reg -instcombine -print-after-all -S < %s 2>&1 | FileCheck %s
+define void @tester(){
+  ret void
+}
+
+define void @foo(){
+  ret void
+}
+
+;CHECK: IR Dump After Promote Memory to Register
+;CHECK: IR Dump After Combine redundant instructions
+;CHECK: IR Dump After Module Verifier
+;CHECK-NOT: IR Dump After Print Module IR