[Debugify] Print the output to stderr

Currently debugify prints it's output to stdout,
with this patch all the output generated goes to stderr.

This change lets us use debugify without taking away
the ability to pipe the output to other llvm tools.

llvm-svn: 332642
diff --git a/llvm/test/DebugInfo/debugify-each.ll b/llvm/test/DebugInfo/debugify-each.ll
index 09af37f..b3e08ff 100644
--- a/llvm/test/DebugInfo/debugify-each.ll
+++ b/llvm/test/DebugInfo/debugify-each.ll
@@ -1,15 +1,18 @@
-; RUN: opt -debugify-each -O3 -S -o /dev/null < %s > %t
+; RUN: opt -debugify-each -O3 -S -o /dev/null < %s 2> %t
 ; RUN: FileCheck %s -input-file=%t -check-prefix=MODULE-PASS
 ; RUN: FileCheck %s -input-file=%t -check-prefix=FUNCTION-PASS
 
-; RUN: opt -enable-debugify -debugify-each -O3 -S -o /dev/null < %s > %t
+; RUN: opt -enable-debugify -debugify-each -O3 -S -o /dev/null < %s 2> %t
 ; RUN: FileCheck %s -input-file=%t -check-prefix=MODULE-PASS
 ; RUN: FileCheck %s -input-file=%t -check-prefix=FUNCTION-PASS
 
-; RUN: opt -debugify-each -instrprof -instrprof -sroa -sccp -S -o /dev/null < %s > %t
+; RUN: opt -debugify-each -instrprof -instrprof -sroa -sccp -S -o /dev/null < %s 2> %t
 ; RUN: FileCheck %s -input-file=%t -check-prefix=MODULE-PASS
 ; RUN: FileCheck %s -input-file=%t -check-prefix=FUNCTION-PASS
 
+; Verify that debugify each can be safely used with piping
+; RUN: opt -debugify-each -O1 < %s | opt -O2 -o /dev/null
+
 define void @foo() {
   ret void
 }
diff --git a/llvm/test/DebugInfo/debugify.ll b/llvm/test/DebugInfo/debugify.ll
index c31105b..fd26537 100644
--- a/llvm/test/DebugInfo/debugify.ll
+++ b/llvm/test/DebugInfo/debugify.ll
@@ -13,13 +13,17 @@
 ; 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
+; RUN: opt -enable-debugify -S -o - < %s 2>&1 | FileCheck %s -check-prefix=PASS
+
+; Verify that debugify can be safely used with piping
+; RUN: opt -enable-debugify -O1 < %s | opt -O2 -o /dev/null
+; RUN: opt -debugify -mem2reg -check-debugify < %s | opt -O2 -o /dev/null
 
 ; CHECK-LABEL: define void @foo
 define void @foo() {
diff --git a/llvm/test/Transforms/Mem2Reg/PromoteMemToRegister.ll b/llvm/test/Transforms/Mem2Reg/PromoteMemToRegister.ll
index 58afb7d..0822190 100644
--- a/llvm/test/Transforms/Mem2Reg/PromoteMemToRegister.ll
+++ b/llvm/test/Transforms/Mem2Reg/PromoteMemToRegister.ll
@@ -1,5 +1,5 @@
 ; Simple sanity check testcase.  Both alloca's should be eliminated.
-; RUN: opt < %s -debugify -mem2reg -check-debugify -S | FileCheck %s
+; RUN: opt < %s -debugify -mem2reg -check-debugify -S 2>&1 | FileCheck %s
 
 ; CHECK-NOT: alloca
 ; CHECK: CheckModuleDebugify [{{.*}}]: PASS