diff mbox

Support no newline in print_gimple_stmt

Message ID 56f3378c-e4ed-6120-4057-fdc2c2d9428d@suse.cz
State New
Headers show

Commit Message

Martin Liška Nov. 10, 2016, 3:36 p.m. UTC
I've just noticed that tree-ssa-dse wrongly prints a new line to dump file.
For the next stage1, I'll go through usages of print_gimple_stmt and remove
extra new lines like:

gcc/auto-profile.c:      print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
gcc/auto-profile.c-      fprintf (dump_file, "\n");

Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.

Ready to be installed?
Martin

Comments

Richard Biener Nov. 11, 2016, 12:10 p.m. UTC | #1
On Thu, Nov 10, 2016 at 4:36 PM, Martin Liška <mliska@suse.cz> wrote:
> I've just noticed that tree-ssa-dse wrongly prints a new line to dump file.
> For the next stage1, I'll go through usages of print_gimple_stmt and remove
> extra new lines like:
>
> gcc/auto-profile.c:      print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
> gcc/auto-profile.c-      fprintf (dump_file, "\n");
>
> Patch can bootstrap on ppc64le-redhat-linux and survives regression tests.
>
> Ready to be installed?

Err, why not just remove the excess newlines (and drop the ' quotes)?

Richard.

> Martin
diff mbox

Patch

From ab1ed77381f78a8940ca250ee0f5ef5cd6b87e7f Mon Sep 17 00:00:00 2001
From: marxin <mliska@suse.cz>
Date: Thu, 10 Nov 2016 14:54:00 +0100
Subject: [PATCH] Support no newline in print_gimple_stmt

gcc/ChangeLog:

2016-11-10  Martin Liska  <mliska@suse.cz>

	* gimple-pretty-print.c (print_gimple_stmt): Add new argument.
	* gimple-pretty-print.h (print_gimple_stmt): Declare the new
	argument.
	* tree-ssa-dse.c (dse_optimize_stmt): Use the argument to not to
	print a newline.
---
 gcc/gimple-pretty-print.c | 7 +++++--
 gcc/gimple-pretty-print.h | 2 +-
 gcc/tree-ssa-dse.c        | 5 +++--
 3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index f588f5e..8538911 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -76,13 +76,16 @@  debug_gimple_stmt (gimple *gs)
    FLAGS as in pp_gimple_stmt_1.  */
 
 void
-print_gimple_stmt (FILE *file, gimple *g, int spc, int flags)
+print_gimple_stmt (FILE *file, gimple *g, int spc, int flags,
+		   bool newline)
 {
   pretty_printer buffer;
   pp_needs_newline (&buffer) = true;
   buffer.buffer->stream = file;
   pp_gimple_stmt_1 (&buffer, g, spc, flags);
-  pp_newline_and_flush (&buffer);
+  if (newline)
+    pp_newline (&buffer);
+  pp_flush (&buffer);
 }
 
 DEBUG_FUNCTION void
diff --git a/gcc/gimple-pretty-print.h b/gcc/gimple-pretty-print.h
index f8eef99..6890cfb 100644
--- a/gcc/gimple-pretty-print.h
+++ b/gcc/gimple-pretty-print.h
@@ -27,7 +27,7 @@  along with GCC; see the file COPYING3.  If not see
 extern void debug_gimple_stmt (gimple *);
 extern void debug_gimple_seq (gimple_seq);
 extern void print_gimple_seq (FILE *, gimple_seq, int, int);
-extern void print_gimple_stmt (FILE *, gimple *, int, int);
+extern void print_gimple_stmt (FILE *, gimple *, int, int, bool newline = true);
 extern void debug (gimple &ref);
 extern void debug (gimple *ptr);
 extern void print_gimple_expr (FILE *, gimple *, int, int);
diff --git a/gcc/tree-ssa-dse.c b/gcc/tree-ssa-dse.c
index 372a0be..b1a8c5d 100644
--- a/gcc/tree-ssa-dse.c
+++ b/gcc/tree-ssa-dse.c
@@ -237,7 +237,8 @@  dse_optimize_stmt (gimple_stmt_iterator *gsi)
 	      if (dump_file && (dump_flags & TDF_DETAILS))
 		{
 		  fprintf (dump_file, "  Deleted dead call '");
-		  print_gimple_stmt (dump_file, gsi_stmt (*gsi), dump_flags, 0);
+		  print_gimple_stmt (dump_file, gsi_stmt (*gsi), dump_flags, 0,
+				     false);
 		  fprintf (dump_file, "'\n");
 		}
 
@@ -293,7 +294,7 @@  dse_optimize_stmt (gimple_stmt_iterator *gsi)
       if (dump_file && (dump_flags & TDF_DETAILS))
 	{
 	  fprintf (dump_file, "  Deleted dead store '");
-	  print_gimple_stmt (dump_file, gsi_stmt (*gsi), dump_flags, 0);
+	  print_gimple_stmt (dump_file, gsi_stmt (*gsi), dump_flags, 0, false);
 	  fprintf (dump_file, "'\n");
 	}
 
-- 
2.10.1