diff mbox

[RFC] Dump ssaname info for default defs

Message ID 566B024F.404@mentor.com
State New
Headers show

Commit Message

Tom de Vries Dec. 11, 2015, 5:05 p.m. UTC
Hi,

atm, we dump ssa-name info for lhs-es of statements. That leaves out the 
ssa names with default defs.

This proof-of-concept patch prints the ssa-name info for default defs, 
in the following format:
...
__attribute__((noclone, noinline))
bar (intD.6 * cD.1755, intD.6 * dD.1756)
# PT = nonlocal
# DEFAULT_DEF c_2(D)
# PT = { D.1762 } (nonlocal)
# ALIGN = 4, MISALIGN = 0
# DEFAULT_DEF d_4(D)
{
;;   basic block 2, loop depth 0, count 0, freq 10000, maybe hot
;;    prev block 0, next block 1, flags: (NEW, REACHABLE)
;;    pred:       ENTRY [100.0%]  (FALLTHRU,EXECUTABLE)
   # .MEM_3 = VDEF <.MEM_1(D)>
   *c_2(D) = 1;
   # .MEM_5 = VDEF <.MEM_3>
   *d_4(D) = 2;
   # VUSE <.MEM_5>
   return;
;;    succ:       EXIT [100.0%]  (EXECUTABLE)

}
...

Good idea? Any further comments, f.i. on formatting?

Thanks,
- Tom

Comments

Richard Biener Dec. 14, 2015, 8:47 a.m. UTC | #1
On Fri, Dec 11, 2015 at 6:05 PM, Tom de Vries <Tom_deVries@mentor.com> wrote:
> Hi,
>
> atm, we dump ssa-name info for lhs-es of statements. That leaves out the ssa
> names with default defs.
>
> This proof-of-concept patch prints the ssa-name info for default defs, in
> the following format:
> ...
> __attribute__((noclone, noinline))
> bar (intD.6 * cD.1755, intD.6 * dD.1756)
> # PT = nonlocal
> # DEFAULT_DEF c_2(D)
> # PT = { D.1762 } (nonlocal)
> # ALIGN = 4, MISALIGN = 0
> # DEFAULT_DEF d_4(D)
> {
> ;;   basic block 2, loop depth 0, count 0, freq 10000, maybe hot
> ;;    prev block 0, next block 1, flags: (NEW, REACHABLE)
> ;;    pred:       ENTRY [100.0%]  (FALLTHRU,EXECUTABLE)
>   # .MEM_3 = VDEF <.MEM_1(D)>
>   *c_2(D) = 1;
>   # .MEM_5 = VDEF <.MEM_3>
>   *d_4(D) = 2;
>   # VUSE <.MEM_5>
>   return;
> ;;    succ:       EXIT [100.0%]  (EXECUTABLE)
>
> }
> ...
>
> Good idea? Any further comments, f.i. on formatting?

I've had a similar patch in my dev tree for quite some while but never
pushed it because
of "formatting"...

That said,

+  if (gimple_in_ssa_p (fun))

Please add flags & TDF_ALIAS here to avoid issues with dump-file scanning.

+    {
+      arg = DECL_ARGUMENTS (fndecl);
+      while (arg)
+       {
+         tree def = ssa_default_def (fun, arg);
+         if (flags & TDF_ALIAS)
+           dump_ssaname_info_to_file (file, def);
+         fprintf (file, "# DEFAULT_DEF ");
+         print_generic_expr (file, def, dump_flags);

Rather than

# DEFAULT_DEF d_4(D)

I'd print

d_4(D) = GIMPLE_NOP;

(or how gimple-nop is printed - that is, just print the def-stmt).

My local patch simply adjusted the dumping of function
locals, thus I amended the existing

      if (gimple_in_ssa_p (cfun))
        for (ix = 1; ix < num_ssa_names; ++ix)
          {
            tree name = ssa_name (ix);
            if (name && !SSA_NAME_VAR (name))
              {

loop.  Of course that intermixed default-defs with other anonymous
SSA vars which might be a little confusing.

But prepending the list of locals with

   type d_4(D) = NOP();

together with SSA info might be the best.  Note there is also the
static chain and the result decl (if DECL_BY_REFERENCE) to print.

Richard.

+         fprintf (file, "\n");
+         arg = DECL_CHAIN (arg);
+       }
+    }


- Tom
diff mbox

Patch

Dump ssaname info for default defs

---
 gcc/gimple-pretty-print.c | 11 +++++++++++
 gcc/tree-cfg.c            | 16 ++++++++++++++++
 2 files changed, 27 insertions(+)

diff --git a/gcc/gimple-pretty-print.c b/gcc/gimple-pretty-print.c
index f1abf5c..75a3036 100644
--- a/gcc/gimple-pretty-print.c
+++ b/gcc/gimple-pretty-print.c
@@ -1887,6 +1887,17 @@  dump_ssaname_info (pretty_printer *buffer, tree node, int spc)
     }
 }
 
+extern void dump_ssaname_info_to_file (FILE *, tree);
+
+void
+dump_ssaname_info_to_file (FILE *file, tree node)
+{
+  pretty_printer buffer;
+  pp_needs_newline (&buffer) = true;
+  buffer.buffer->stream = file;
+  dump_ssaname_info (&buffer, node, 0);
+  pp_flush (&buffer);
+}
 
 /* Dump a PHI node PHI.  BUFFER, SPC and FLAGS are as in pp_gimple_stmt_1.
    The caller is responsible for calling pp_flush on BUFFER to finalize
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 0c624aa..21cf7a1 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -7312,6 +7312,7 @@  move_sese_region_to_fn (struct function *dest_cfun, basic_block entry_bb,
   return bb;
 }
 
+extern void dump_ssaname_info_to_file (FILE *, tree);
 
 /* Dump FUNCTION_DECL FN to file FILE using FLAGS (see TDF_* in dumpfile.h)
    */
@@ -7369,6 +7370,21 @@  dump_function_to_file (tree fndecl, FILE *file, int flags)
     }
   fprintf (file, ")\n");
 
+  if (gimple_in_ssa_p (fun))
+    {
+      arg = DECL_ARGUMENTS (fndecl);
+      while (arg)
+	{
+	  tree def = ssa_default_def (fun, arg);
+	  if (flags & TDF_ALIAS)
+	    dump_ssaname_info_to_file (file, def);
+	  fprintf (file, "# DEFAULT_DEF ");
+	  print_generic_expr (file, def, dump_flags);
+	  fprintf (file, "\n");
+	  arg = DECL_CHAIN (arg);
+	}
+    }
+
   if (flags & TDF_VERBOSE)
     print_node (file, "", fndecl, 2);