improve debug of codegen

- fix printing of ISL stmt and parameter names
- move dot_scop* functions outside of anonymous namespace.

  * graphite-isl-ast-to-gimple.c: Include tree-cfg.h.
  (translate_isl_ast_node_user): Add more dumps: call print_loops_bb.
  * graphite-scop-detection.c (dot_all_scops_1): Moved out of
  anonymous namespace.
  * graphite-sese-to-poly.c (ssa_name_version_typesize): Remove.
  (isl_id_for_pbb): Use a buffer of size 10.
  (isl_id_for_ssa_name): Same.
  * sese.c (set_rename): Add more dumps.

Co-Authored-By: Sebastian Pop <s.pop@samsung.com>

From-SVN: r229782
This commit is contained in:
Aditya Kumar 2015-11-04 20:59:12 +00:00 committed by Sebastian Pop
parent b76e99102f
commit 1b38d3ecfe
5 changed files with 231 additions and 200 deletions

View File

@ -1,3 +1,15 @@
2015-11-04 Aditya Kumar <aditya.k7@samsung.com>
Sebastian Pop <s.pop@samsung.com>
* graphite-isl-ast-to-gimple.c: Include tree-cfg.h.
(translate_isl_ast_node_user): Add more dumps: call print_loops_bb.
* graphite-scop-detection.c (dot_all_scops_1): Moved out of
anonymous namespace.
* graphite-sese-to-poly.c (ssa_name_version_typesize): Remove.
(isl_id_for_pbb): Use a buffer of size 10.
(isl_id_for_ssa_name): Same.
* sese.c (set_rename): Add more dumps.
2015-11-04 Nathan Sidwell <nathan@codesourcery.com>
* omp-low.c (struct omp_context): Remove reduction_map field.

View File

@ -62,6 +62,7 @@ extern "C" {
#include "ssa-iterators.h"
#include <map>
#include "graphite-isl-ast-to-gimple.h"
#include "tree-cfg.h"
/* This flag is set when an error occurred during the translation of
ISL AST to Gimple. */
@ -793,10 +794,23 @@ translate_isl_ast_node_user (__isl_keep isl_ast_node *node,
build_iv_mapping (iv_map, gbb, user_expr, ip, pbb->scop->scop_info->region);
isl_ast_expr_free (user_expr);
if (dump_file)
{
fprintf (dump_file, "[codegen] copying");
print_loops_bb (dump_file, GBB_BB (gbb), 0, 3);
}
next_e = copy_bb_and_scalar_dependences (GBB_BB (gbb),
pbb->scop->scop_info, next_e,
iv_map,
&graphite_regenerate_error);
if (dump_file)
{
fprintf (dump_file, "[codegen] to");
print_loops_bb (dump_file, next_e->src, 0, 3);
}
iv_map.release ();
mark_virtual_operands_for_renaming (cfun);
update_ssa (TODO_update_ssa);

View File

@ -88,6 +88,200 @@ public:
if (dump_file && (dump_flags & TDF_DETAILS)) { args; } \
} while (0);
/* Pretty print to FILE all the SCoPs in DOT format and mark them with
different colors. If there are not enough colors, paint the
remaining SCoPs in gray.
Special nodes:
- "*" after the node number denotes the entry of a SCoP,
- "#" after the node number denotes the exit of a SCoP,
- "()" around the node number denotes the entry or the
exit nodes of the SCOP. These are not part of SCoP. */
static void
dot_all_scops_1 (FILE *file, vec<scop_p> scops)
{
basic_block bb;
edge e;
edge_iterator ei;
scop_p scop;
const char *color;
int i;
/* Disable debugging while printing graph. */
int tmp_dump_flags = dump_flags;
dump_flags = 0;
fprintf (file, "digraph all {\n");
FOR_ALL_BB_FN (bb, cfun)
{
int part_of_scop = false;
/* Use HTML for every bb label. So we are able to print bbs
which are part of two different SCoPs, with two different
background colors. */
fprintf (file, "%d [label=<\n <TABLE BORDER=\"0\" CELLBORDER=\"1\" ",
bb->index);
fprintf (file, "CELLSPACING=\"0\">\n");
/* Select color for SCoP. */
FOR_EACH_VEC_ELT (scops, i, scop)
{
sese_l region = scop->scop_info->region;
if (bb_in_sese_p (bb, region) || (region.exit->dest == bb)
|| (region.entry->dest == bb))
{
switch (i % 17)
{
case 0: /* red */
color = "#e41a1c";
break;
case 1: /* blue */
color = "#377eb8";
break;
case 2: /* green */
color = "#4daf4a";
break;
case 3: /* purple */
color = "#984ea3";
break;
case 4: /* orange */
color = "#ff7f00";
break;
case 5: /* yellow */
color = "#ffff33";
break;
case 6: /* brown */
color = "#a65628";
break;
case 7: /* rose */
color = "#f781bf";
break;
case 8:
color = "#8dd3c7";
break;
case 9:
color = "#ffffb3";
break;
case 10:
color = "#bebada";
break;
case 11:
color = "#fb8072";
break;
case 12:
color = "#80b1d3";
break;
case 13:
color = "#fdb462";
break;
case 14:
color = "#b3de69";
break;
case 15:
color = "#fccde5";
break;
case 16:
color = "#bc80bd";
break;
default: /* gray */
color = "#999999";
}
fprintf (file, " <TR><TD WIDTH=\"50\" BGCOLOR=\"%s\">",
color);
if (!bb_in_sese_p (bb, region))
fprintf (file, " (");
if (bb == region.entry->dest && bb == region.exit->dest)
fprintf (file, " %d*# ", bb->index);
else if (bb == region.entry->dest)
fprintf (file, " %d* ", bb->index);
else if (bb == region.exit->dest)
fprintf (file, " %d# ", bb->index);
else
fprintf (file, " %d ", bb->index);
fprintf (file, "{lp_%d}", bb->loop_father->num);
if (!bb_in_sese_p (bb, region))
fprintf (file, ")");
fprintf (file, "</TD></TR>\n");
part_of_scop = true;
}
}
if (!part_of_scop)
{
fprintf (file, " <TR><TD WIDTH=\"50\" BGCOLOR=\"#ffffff\">");
fprintf (file, " %d {lp_%d} </TD></TR>\n", bb->index,
bb->loop_father->num);
}
fprintf (file, " </TABLE>>, shape=box, style=\"setlinewidth(0)\"]\n");
}
FOR_ALL_BB_FN (bb, cfun)
{
FOR_EACH_EDGE (e, ei, bb->succs)
fprintf (file, "%d -> %d;\n", bb->index, e->dest->index);
}
fputs ("}\n\n", file);
/* Enable debugging again. */
dump_flags = tmp_dump_flags;
}
/* Display all SCoPs using dotty. */
DEBUG_FUNCTION void
dot_all_scops (vec<scop_p> scops)
{
/* When debugging, enable the following code. This cannot be used
in production compilers because it calls "system". */
#if 0
int x;
FILE *stream = fopen ("/tmp/allscops.dot", "w");
gcc_assert (stream);
dot_all_scops_1 (stream, scops);
fclose (stream);
x = system ("dotty /tmp/allscops.dot &");
#else
dot_all_scops_1 (stderr, scops);
#endif
}
/* Display all SCoPs using dotty. */
DEBUG_FUNCTION void
dot_scop (scop_p scop)
{
auto_vec<scop_p, 1> scops;
if (scop)
scops.safe_push (scop);
/* When debugging, enable the following code. This cannot be used
in production compilers because it calls "system". */
#if 0
{
int x;
FILE *stream = fopen ("/tmp/allscops.dot", "w");
gcc_assert (stream);
dot_all_scops_1 (stream, scops);
fclose (stream);
x = system ("dotty /tmp/allscops.dot &");
}
#else
dot_all_scops_1 (stderr, scops);
#endif
}
/* Return true if BB is empty, contains only DEBUG_INSNs. */
@ -1228,201 +1422,6 @@ scop_detection::harmful_stmt_in_bb (sese_l scop, basic_block bb) const
return false;
}
/* Pretty print to FILE all the SCoPs in DOT format and mark them with
different colors. If there are not enough colors, paint the
remaining SCoPs in gray.
Special nodes:
- "*" after the node number denotes the entry of a SCoP,
- "#" after the node number denotes the exit of a SCoP,
- "()" around the node number denotes the entry or the
exit nodes of the SCOP. These are not part of SCoP. */
static void
dot_all_scops_1 (FILE *file, vec<scop_p> scops)
{
basic_block bb;
edge e;
edge_iterator ei;
scop_p scop;
const char *color;
int i;
/* Disable debugging while printing graph. */
int tmp_dump_flags = dump_flags;
dump_flags = 0;
fprintf (file, "digraph all {\n");
FOR_ALL_BB_FN (bb, cfun)
{
int part_of_scop = false;
/* Use HTML for every bb label. So we are able to print bbs
which are part of two different SCoPs, with two different
background colors. */
fprintf (file, "%d [label=<\n <TABLE BORDER=\"0\" CELLBORDER=\"1\" ",
bb->index);
fprintf (file, "CELLSPACING=\"0\">\n");
/* Select color for SCoP. */
FOR_EACH_VEC_ELT (scops, i, scop)
{
sese_l region = scop->scop_info->region;
if (bb_in_sese_p (bb, region) || (region.exit->dest == bb)
|| (region.entry->dest == bb))
{
switch (i % 17)
{
case 0: /* red */
color = "#e41a1c";
break;
case 1: /* blue */
color = "#377eb8";
break;
case 2: /* green */
color = "#4daf4a";
break;
case 3: /* purple */
color = "#984ea3";
break;
case 4: /* orange */
color = "#ff7f00";
break;
case 5: /* yellow */
color = "#ffff33";
break;
case 6: /* brown */
color = "#a65628";
break;
case 7: /* rose */
color = "#f781bf";
break;
case 8:
color = "#8dd3c7";
break;
case 9:
color = "#ffffb3";
break;
case 10:
color = "#bebada";
break;
case 11:
color = "#fb8072";
break;
case 12:
color = "#80b1d3";
break;
case 13:
color = "#fdb462";
break;
case 14:
color = "#b3de69";
break;
case 15:
color = "#fccde5";
break;
case 16:
color = "#bc80bd";
break;
default: /* gray */
color = "#999999";
}
fprintf (file, " <TR><TD WIDTH=\"50\" BGCOLOR=\"%s\">",
color);
if (!bb_in_sese_p (bb, region))
fprintf (file, " (");
if (bb == region.entry->dest && bb == region.exit->dest)
fprintf (file, " %d*# ", bb->index);
else if (bb == region.entry->dest)
fprintf (file, " %d* ", bb->index);
else if (bb == region.exit->dest)
fprintf (file, " %d# ", bb->index);
else
fprintf (file, " %d ", bb->index);
fprintf (file, "{lp_%d}", bb->loop_father->num);
if (!bb_in_sese_p (bb, region))
fprintf (file, ")");
fprintf (file, "</TD></TR>\n");
part_of_scop = true;
}
}
if (!part_of_scop)
{
fprintf (file, " <TR><TD WIDTH=\"50\" BGCOLOR=\"#ffffff\">");
fprintf (file, " %d {lp_%d} </TD></TR>\n", bb->index,
bb->loop_father->num);
}
fprintf (file, " </TABLE>>, shape=box, style=\"setlinewidth(0)\"]\n");
}
FOR_ALL_BB_FN (bb, cfun)
{
FOR_EACH_EDGE (e, ei, bb->succs)
fprintf (file, "%d -> %d;\n", bb->index, e->dest->index);
}
fputs ("}\n\n", file);
/* Enable debugging again. */
dump_flags = tmp_dump_flags;
}
/* Display all SCoPs using dotty. */
DEBUG_FUNCTION void
dot_all_scops (vec<scop_p> scops)
{
/* When debugging, enable the following code. This cannot be used
in production compilers because it calls "system". */
#if 0
int x;
FILE *stream = fopen ("/tmp/allscops.dot", "w");
gcc_assert (stream);
dot_all_scops_1 (stream, scops);
fclose (stream);
x = system ("dotty /tmp/allscops.dot &");
#else
dot_all_scops_1 (stderr, scops);
#endif
}
/* Display all SCoPs using dotty. */
DEBUG_FUNCTION void
dot_scop (scop_p scop)
{
auto_vec<scop_p, 1> scops;
if (scop)
scops.safe_push (scop);
/* When debugging, enable the following code. This cannot be used
in production compilers because it calls "system". */
#if 0
{
int x;
FILE *stream = fopen ("/tmp/allscops.dot", "w");
gcc_assert (stream);
dot_all_scops_1 (stream, scops);
fclose (stream);
x = system ("dotty /tmp/allscops.dot &");
}
#else
dot_all_scops_1 (stderr, scops);
#endif
}
/* Return true when the body of LOOP has statements that can be represented as a
valid scop. */

View File

@ -67,9 +67,6 @@ extern "C" {
#include "tree-ssa-propagate.h"
#include "graphite-sese-to-poly.h"
static const unsigned ssa_name_version_typesize = sizeof(unsigned);
/* Assigns to RES the value of the INTEGER_CST T. */
static inline void
@ -201,7 +198,7 @@ reduction_phi_p (sese_l &region, gphi_iterator *psi)
static isl_id *
isl_id_for_pbb (scop_p s, poly_bb_p pbb)
{
char name[ssa_name_version_typesize];
char name[10];
snprintf (name, sizeof (name), "S_%d", pbb_index (pbb));
return isl_id_alloc (s->isl_context, name, pbb);
}
@ -401,7 +398,7 @@ isl_id_for_ssa_name (scop_p s, tree e)
id = isl_id_alloc (s->isl_context, name, e);
else
{
char name1[ssa_name_version_typesize];
char name1[10];
snprintf (name1, sizeof (name1), "P_%d", SSA_NAME_VERSION (e));
id = isl_id_alloc (s->isl_context, name1, e);
}

View File

@ -373,6 +373,15 @@ static void
set_rename (rename_map_type *rename_map, tree old_name, tree expr,
sese_info_p region)
{
if (dump_file)
{
fprintf (dump_file, "[codegen] setting rename: old_name = ");
print_generic_expr (dump_file, old_name, 0);
fprintf (dump_file, ", new_name = ");
print_generic_expr (dump_file, expr, 0);
fprintf (dump_file, "\n");
}
if (old_name == expr)
return;