diff options
author | Li Feng <nemokingdom@gmail.com> | 2009-11-25 04:50:45 +0000 |
---|---|---|
committer | Sebastian Pop <spop@gcc.gnu.org> | 2009-11-25 04:50:45 +0000 |
commit | cd43e5d73391016c43b01a2b6ea68c254a1d68de (patch) | |
tree | b32ca9f2e7b90973d2cfda8f5b37cbfaebacec25 | |
parent | aeda6535863f3d604fa9e3c19c264adaf546f264 (diff) | |
download | gcc-cd43e5d73391016c43b01a2b6ea68c254a1d68de.zip gcc-cd43e5d73391016c43b01a2b6ea68c254a1d68de.tar.gz gcc-cd43e5d73391016c43b01a2b6ea68c254a1d68de.tar.bz2 |
graphite-sese-to-poly.c (write_alias_graph_to_ascii_dimacs): New.
2009-09-25 Li Feng <nemokingdom@gmail.com>
* graphite-sese-to-poly.c (write_alias_graph_to_ascii_dimacs): New.
(build_scop_drs): When debugging, write the alias graph to file,
otherwise, should be disabled.
From-SVN: r154553
-rw-r--r-- | gcc/ChangeLog.graphite | 6 | ||||
-rw-r--r-- | gcc/graphite-sese-to-poly.c | 52 |
2 files changed, 58 insertions, 0 deletions
diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index c9e5513..419f882 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,9 @@ +2009-09-25 Li Feng <nemokingdom@gmail.com> + + * graphite-sese-to-poly.c (write_alias_graph_to_ascii_dimacs): New. + (build_scop_drs): When debugging, write the alias graph to file, + otherwise, should be disabled. + 2009-09-17 Sebastian Pop <sebastian.pop@amd.com> * graphite-scop-detection.c (stmt_simple_memref_p): Removed. diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index e2c9cf8..4dc738d 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -1708,6 +1708,40 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb) dr, DR_NUM_DIMENSIONS (dr)); } +/* Write to FILE the alias graph of data references DRS. */ + +static inline bool +write_alias_graph_to_ascii_dimacs (FILE *file, char *comment, + VEC (data_reference_p, heap) *drs) +{ + int num_vertex = VEC_length (data_reference_p, drs); + int edge_num = 0; + data_reference_p dr1, dr2; + int i, j; + + if (num_vertex == 0) + return true; + + for (i = 0; VEC_iterate (data_reference_p, drs, i, dr1); i++) + for (j = i + 1; VEC_iterate (data_reference_p, drs, j, dr2); j++) + if (dr_may_alias_p (dr1, dr2)) + edge_num++; + + fprintf (file, "$\n"); + + if (comment) + fprintf (file, "c %s\n", comment); + + fprintf (file, "p edge %d %d\n", num_vertex, edge_num); + + for (i = 0; VEC_iterate (data_reference_p, drs, i, dr1); i++) + for (j = i + 1; VEC_iterate (data_reference_p, drs, j, dr2); j++) + if (dr_may_alias_p (dr1, dr2)) + fprintf (file, "e %d %d\n", i + 1, j + 1); + + return true; +} + static void partition_drs_to_sets (VEC (data_reference_p, heap) **drs, int choice, bool (* edge_exist_p) (const struct data_reference *, @@ -1802,6 +1836,24 @@ build_scop_drs (scop_p scop) build_alias_set_for_drs (&drs); build_base_obj_set_for_drs (&drs); + /* When debugging, enable the following code. This cannot be used + in production compilers. */ +#if 0 + { + char comment[100]; + FILE *file; + + file = fopen ("/tmp/dr_alias_graph", "ab"); + if (file) + { + snprintf (comment, sizeof (comment), "%s %s", main_input_filename, + current_function_name ()); + write_alias_graph_to_ascii_dimacs (file, comment, drs); + fclose (file); + } + } +#endif + VEC_free (data_reference_p, heap, drs); for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++) |