diff mbox

Improve readability of debug_tree() dumps for SSA_NAME and VECTOR_CST

Message ID alpine.DEB.2.20.13.1608220736200.3547@idea
State New
Headers show

Commit Message

Patrick Palka Aug. 22, 2016, 11:39 a.m. UTC
On Mon, 22 Aug 2016, Richard Biener wrote:

> On Sat, Aug 20, 2016 at 1:27 AM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> > * For SSA_NAME: Print the ssa name's def stmt on its own line.
> >
> > Before:
> >  <ssa_name 0x7ffff6a26ca8
> >     type <vector_type 0x7ffff6a09bd0
> >         type <integer_type 0x7ffff688a888 unsigned int sizes-gimplified public unsigned SI
> >             size <integer_cst 0x7ffff6886ca8 constant 32>
> >             unit size <integer_cst 0x7ffff6886cc0 constant 4>
> >             align 32 symtab 0 alias set -1 canonical type 0x7ffff688a888 precision 32 min <integer_cst 0x7ffff6886f30 0> max <integer_cst 0x7ffff6886f18 4294967295> context <translation_unit_decl 0x7ffff6893348 D.2203>
> >             pointer_to_this <pointer_type 0x7ffff68aae70>>
> >         unsigned V8SI
> >         size <integer_cst 0x7ffff68a2168 constant 256>
> >         unit size <integer_cst 0x7ffff68a21f8 constant 32>
> >         align 256 symtab 0 alias set 1 canonical type 0x7ffff6a09bd0 nunits 8
> >         pointer_to_this <pointer_type 0x7ffff6a09d20>>
> >     visited var <var_decl 0x7ffff6a046c0 vect__2.15>def_stmt vect__2.15_101 = vect__1.14_99 & { 1, 1, 1, 1, 1, 1, 1, 1 };
> >
> >     version 101>
> >
> > After:
> > (gdb) print debug_tree (op0)
> >  <ssa_name 0x7ffff6a26ca8
> >     type <vector_type 0x7ffff6a09bd0
> >         type <integer_type 0x7ffff688a888 unsigned int sizes-gimplified public unsigned SI
> >             size <integer_cst 0x7ffff6886ca8 constant 32>
> >             unit size <integer_cst 0x7ffff6886cc0 constant 4>
> >             align 32 symtab 0 alias set -1 canonical type 0x7ffff688a888 precision 32 min <integer_cst 0x7ffff6886f30 0> max <integer_cst 0x7ffff6886f18 4294967295> context <translation_unit_decl 0x7ffff6893348 D.2203>
> >             pointer_to_this <pointer_type 0x7ffff68aae70>>
> >         unsigned V8SI
> >         size <integer_cst 0x7ffff68a2168 constant 256>
> >         unit size <integer_cst 0x7ffff68a21f8 constant 32>
> >         align 256 symtab 0 alias set 1 canonical type 0x7ffff6a09bd0 nunits 8
> >         pointer_to_this <pointer_type 0x7ffff6a09d20>>
> >     visited var <var_decl 0x7ffff6a046c0 vect__2.15>
> >     def_stmt vect__2.15_101 = vect__1.14_99 & { 1, 1, 1, 1, 1, 1, 1, 1 };
> >
> >     version 101>
> >
> > * For VECTOR_CST: Coalesce the output of identical consecutive elt values.
> >
> > Before:
> >  <vector_cst 0x7ffff6a23870
> >     type <vector_type 0x7ffff6a09bd0
> >         type <integer_type 0x7ffff688a888 unsigned int sizes-gimplified public unsigned SI
> >             size <integer_cst 0x7ffff6886ca8 constant 32>
> >             unit size <integer_cst 0x7ffff6886cc0 constant 4>
> >             align 32 symtab 0 alias set -1 canonical type 0x7ffff688a888 precision 32 min <integer_cst 0x7ffff6886f30 0> max <integer_cst 0x7ffff6886f18 4294967295> context <translation_unit_decl 0x7ffff6893348 D.2203>
> >             pointer_to_this <pointer_type 0x7ffff68aae70>>
> >         unsigned V8SI
> >         size <integer_cst 0x7ffff68a2168 constant 256>
> >         unit size <integer_cst 0x7ffff68a21f8 constant 32>
> >         align 256 symtab 0 alias set 1 canonical type 0x7ffff6a09bd0 nunits 8
> >         pointer_to_this <pointer_type 0x7ffff6a09d20>>
> >     constant
> >     elt0:  <integer_cst 0x7ffff69ec840 type <integer_type 0x7ffff69db3f0 ui> constant 0> elt1:  <integer_cst 0x7ffff69ec840 0> elt2:  <integer_cst 0x7ffff69ec840 0> elt3:  <integer_cst 0x7ffff69ec840 0> elt4:  <integer_cst 0x7ffff69ec840 0> elt5:  <integer_cst 0x7ffff69ec840 0> elt6:  <integer_cst 0x7ffff69ec840 0> elt7:  <integer_cst 0x7ffff69ec840 0>>
> >
> > After:
> > (gdb) print debug_tree (op1)
> >  <vector_cst 0x7ffff6a23870
> >     type <vector_type 0x7ffff6a09bd0
> >         type <integer_type 0x7ffff688a888 unsigned int sizes-gimplified public unsigned SI
> >             size <integer_cst 0x7ffff6886ca8 constant 32>
> >             unit size <integer_cst 0x7ffff6886cc0 constant 4>
> >             align 32 symtab 0 alias set -1 canonical type 0x7ffff688a888 precision 32 min <integer_cst 0x7ffff6886f30 0> max <integer_cst 0x7ffff6886f18 4294967295> context <translation_unit_decl 0x7ffff6893348 D.2203>
> >             pointer_to_this <pointer_type 0x7ffff68aae70>>
> >         unsigned V8SI
> >         size <integer_cst 0x7ffff68a2168 constant 256>
> >         unit size <integer_cst 0x7ffff68a21f8 constant 32>
> >         align 256 symtab 0 alias set 1 canonical type 0x7ffff6a09bd0 nunits 8
> >         pointer_to_this <pointer_type 0x7ffff6a09d20>>
> >     constant
> >     elt0...elt7:  <integer_cst 0x7ffff69ec840 type <integer_type 0x7ffff69db3f0 ui> constant 0>>
> >
> > (I also tested the change on non-uniform VECTOR_CSTs.)
> >
> > Does this look OK to commit after bootstrap + regtesting?
> 
> Ok - but can you please try to avoid the excessive newline after the
> def_stmt: line?
> I think the only way to do this currently is to inline
> print_gimple_stmt and adjust it
> accordingly.  Or add a param to 'indent_to' whether to emit the newline.

How does this look?

gcc/ChangeLog:

	* print-tree.c (print_node) [SSA_NAME]: When printing the node's
	def stmt, replace the call to print_gimple_stmt() with its
	inlined body and adjust it to avoid printing an unwanted
	newline by calling pp_flush() instead of pp_newline_and_flush()
	and by not setting pp_needs_newline.
---
 gcc/print-tree.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Richard Biener Aug. 22, 2016, 12:02 p.m. UTC | #1
On Mon, Aug 22, 2016 at 1:39 PM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> On Mon, 22 Aug 2016, Richard Biener wrote:
>
>> On Sat, Aug 20, 2016 at 1:27 AM, Patrick Palka <patrick@parcs.ath.cx> wrote:
>> > * For SSA_NAME: Print the ssa name's def stmt on its own line.
>> >
>> > Before:
>> >  <ssa_name 0x7ffff6a26ca8
>> >     type <vector_type 0x7ffff6a09bd0
>> >         type <integer_type 0x7ffff688a888 unsigned int sizes-gimplified public unsigned SI
>> >             size <integer_cst 0x7ffff6886ca8 constant 32>
>> >             unit size <integer_cst 0x7ffff6886cc0 constant 4>
>> >             align 32 symtab 0 alias set -1 canonical type 0x7ffff688a888 precision 32 min <integer_cst 0x7ffff6886f30 0> max <integer_cst 0x7ffff6886f18 4294967295> context <translation_unit_decl 0x7ffff6893348 D.2203>
>> >             pointer_to_this <pointer_type 0x7ffff68aae70>>
>> >         unsigned V8SI
>> >         size <integer_cst 0x7ffff68a2168 constant 256>
>> >         unit size <integer_cst 0x7ffff68a21f8 constant 32>
>> >         align 256 symtab 0 alias set 1 canonical type 0x7ffff6a09bd0 nunits 8
>> >         pointer_to_this <pointer_type 0x7ffff6a09d20>>
>> >     visited var <var_decl 0x7ffff6a046c0 vect__2.15>def_stmt vect__2.15_101 = vect__1.14_99 & { 1, 1, 1, 1, 1, 1, 1, 1 };
>> >
>> >     version 101>
>> >
>> > After:
>> > (gdb) print debug_tree (op0)
>> >  <ssa_name 0x7ffff6a26ca8
>> >     type <vector_type 0x7ffff6a09bd0
>> >         type <integer_type 0x7ffff688a888 unsigned int sizes-gimplified public unsigned SI
>> >             size <integer_cst 0x7ffff6886ca8 constant 32>
>> >             unit size <integer_cst 0x7ffff6886cc0 constant 4>
>> >             align 32 symtab 0 alias set -1 canonical type 0x7ffff688a888 precision 32 min <integer_cst 0x7ffff6886f30 0> max <integer_cst 0x7ffff6886f18 4294967295> context <translation_unit_decl 0x7ffff6893348 D.2203>
>> >             pointer_to_this <pointer_type 0x7ffff68aae70>>
>> >         unsigned V8SI
>> >         size <integer_cst 0x7ffff68a2168 constant 256>
>> >         unit size <integer_cst 0x7ffff68a21f8 constant 32>
>> >         align 256 symtab 0 alias set 1 canonical type 0x7ffff6a09bd0 nunits 8
>> >         pointer_to_this <pointer_type 0x7ffff6a09d20>>
>> >     visited var <var_decl 0x7ffff6a046c0 vect__2.15>
>> >     def_stmt vect__2.15_101 = vect__1.14_99 & { 1, 1, 1, 1, 1, 1, 1, 1 };
>> >
>> >     version 101>
>> >
>> > * For VECTOR_CST: Coalesce the output of identical consecutive elt values.
>> >
>> > Before:
>> >  <vector_cst 0x7ffff6a23870
>> >     type <vector_type 0x7ffff6a09bd0
>> >         type <integer_type 0x7ffff688a888 unsigned int sizes-gimplified public unsigned SI
>> >             size <integer_cst 0x7ffff6886ca8 constant 32>
>> >             unit size <integer_cst 0x7ffff6886cc0 constant 4>
>> >             align 32 symtab 0 alias set -1 canonical type 0x7ffff688a888 precision 32 min <integer_cst 0x7ffff6886f30 0> max <integer_cst 0x7ffff6886f18 4294967295> context <translation_unit_decl 0x7ffff6893348 D.2203>
>> >             pointer_to_this <pointer_type 0x7ffff68aae70>>
>> >         unsigned V8SI
>> >         size <integer_cst 0x7ffff68a2168 constant 256>
>> >         unit size <integer_cst 0x7ffff68a21f8 constant 32>
>> >         align 256 symtab 0 alias set 1 canonical type 0x7ffff6a09bd0 nunits 8
>> >         pointer_to_this <pointer_type 0x7ffff6a09d20>>
>> >     constant
>> >     elt0:  <integer_cst 0x7ffff69ec840 type <integer_type 0x7ffff69db3f0 ui> constant 0> elt1:  <integer_cst 0x7ffff69ec840 0> elt2:  <integer_cst 0x7ffff69ec840 0> elt3:  <integer_cst 0x7ffff69ec840 0> elt4:  <integer_cst 0x7ffff69ec840 0> elt5:  <integer_cst 0x7ffff69ec840 0> elt6:  <integer_cst 0x7ffff69ec840 0> elt7:  <integer_cst 0x7ffff69ec840 0>>
>> >
>> > After:
>> > (gdb) print debug_tree (op1)
>> >  <vector_cst 0x7ffff6a23870
>> >     type <vector_type 0x7ffff6a09bd0
>> >         type <integer_type 0x7ffff688a888 unsigned int sizes-gimplified public unsigned SI
>> >             size <integer_cst 0x7ffff6886ca8 constant 32>
>> >             unit size <integer_cst 0x7ffff6886cc0 constant 4>
>> >             align 32 symtab 0 alias set -1 canonical type 0x7ffff688a888 precision 32 min <integer_cst 0x7ffff6886f30 0> max <integer_cst 0x7ffff6886f18 4294967295> context <translation_unit_decl 0x7ffff6893348 D.2203>
>> >             pointer_to_this <pointer_type 0x7ffff68aae70>>
>> >         unsigned V8SI
>> >         size <integer_cst 0x7ffff68a2168 constant 256>
>> >         unit size <integer_cst 0x7ffff68a21f8 constant 32>
>> >         align 256 symtab 0 alias set 1 canonical type 0x7ffff6a09bd0 nunits 8
>> >         pointer_to_this <pointer_type 0x7ffff6a09d20>>
>> >     constant
>> >     elt0...elt7:  <integer_cst 0x7ffff69ec840 type <integer_type 0x7ffff69db3f0 ui> constant 0>>
>> >
>> > (I also tested the change on non-uniform VECTOR_CSTs.)
>> >
>> > Does this look OK to commit after bootstrap + regtesting?
>>
>> Ok - but can you please try to avoid the excessive newline after the
>> def_stmt: line?
>> I think the only way to do this currently is to inline
>> print_gimple_stmt and adjust it
>> accordingly.  Or add a param to 'indent_to' whether to emit the newline.
>
> How does this look?

Looks good.

Thanks,
Richard.

> gcc/ChangeLog:
>
>         * print-tree.c (print_node) [SSA_NAME]: When printing the node's
>         def stmt, replace the call to print_gimple_stmt() with its
>         inlined body and adjust it to avoid printing an unwanted
>         newline by calling pp_flush() instead of pp_newline_and_flush()
>         and by not setting pp_needs_newline.
> ---
>  gcc/print-tree.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/gcc/print-tree.c b/gcc/print-tree.c
> index 2baf34a..d775491 100644
> --- a/gcc/print-tree.c
> +++ b/gcc/print-tree.c
> @@ -882,7 +882,12 @@ print_node (FILE *file, const char *prefix, tree node, int indent)
>           print_node_brief (file, "var", SSA_NAME_VAR (node), indent + 4);
>           indent_to (file, indent + 4);
>           fprintf (file, "def_stmt ");
> -         print_gimple_stmt (file, SSA_NAME_DEF_STMT (node), indent + 4, 0);
> +         {
> +           pretty_printer buffer;
> +           buffer.buffer->stream = file;
> +           pp_gimple_stmt_1 (&buffer, SSA_NAME_DEF_STMT (node), indent + 4, 0);
> +           pp_flush (&buffer);
> +         }
>
>           indent_to (file, indent + 4);
>           fprintf (file, "version %u", SSA_NAME_VERSION (node));
> --
> 2.10.0.rc1.53.gfcb49dc
>
diff mbox

Patch

diff --git a/gcc/print-tree.c b/gcc/print-tree.c
index 2baf34a..d775491 100644
--- a/gcc/print-tree.c
+++ b/gcc/print-tree.c
@@ -882,7 +882,12 @@  print_node (FILE *file, const char *prefix, tree node, int indent)
 	  print_node_brief (file, "var", SSA_NAME_VAR (node), indent + 4);
 	  indent_to (file, indent + 4);
 	  fprintf (file, "def_stmt ");
-	  print_gimple_stmt (file, SSA_NAME_DEF_STMT (node), indent + 4, 0);
+	  {
+	    pretty_printer buffer;
+	    buffer.buffer->stream = file;
+	    pp_gimple_stmt_1 (&buffer, SSA_NAME_DEF_STMT (node), indent + 4, 0);
+	    pp_flush (&buffer);
+	  }
 
 	  indent_to (file, indent + 4);
 	  fprintf (file, "version %u", SSA_NAME_VERSION (node));