OSDN Git Service

2009-09-25 Li Feng <nemokingdom@gmail.com>
authorspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Nov 2009 04:50:45 +0000 (04:50 +0000)
committerspop <spop@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 25 Nov 2009 04:50:45 +0000 (04:50 +0000)
* 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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154553 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog.graphite
gcc/graphite-sese-to-poly.c

index c9e5513..419f882 100644 (file)
@@ -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.
 2009-09-17  Sebastian Pop  <sebastian.pop@amd.com>
 
        * graphite-scop-detection.c (stmt_simple_memref_p): Removed.
index e2c9cf8..4dc738d 100644 (file)
@@ -1708,6 +1708,40 @@ build_poly_dr (data_reference_p dr, poly_bb_p pbb)
               dr, DR_NUM_DIMENSIONS (dr));
 }
 
               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 *,
 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);
 
   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++)
   VEC_free (data_reference_p, heap, drs);
 
   for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)