static void mark_nodes_having_upstream_mem_writes (struct graph *rdg) { int v, x; bitmap seen = BITMAP_ALLOC (NULL); for (v = rdg->n_vertices - 1; v >= 0; v--) if (!bitmap_bit_p (seen, v)) { unsigned i; VEC (int, heap) *nodes = VEC_alloc (int, heap, 3); graphds_dfs (rdg, &v, 1, &nodes, false, NULL); FOR_EACH_VEC_ELT (int, nodes, i, x) { if (!bitmap_set_bit (seen, x)) continue; if (RDG_MEM_WRITE_STMT (rdg, x) || predecessor_has_mem_write (rdg, &(rdg->vertices[x])) /* In anti dependences the read should occur before the write, this is why both the read and the write should be placed in the same partition. */ || has_anti_dependence (&(rdg->vertices[x]))) { bitmap_set_bit (upstream_mem_writes, x); } } VEC_free (int, heap, nodes); }
static bool rdg_cannot_recompute_vertex_p (struct graph *rdg, int v) { if (RDG_MEM_WRITE_STMT (rdg, v)) return true; return false; }
static void dot_rdg_1 (FILE *file, struct graph *rdg) { int i; pretty_printer buffer; pp_needs_newline (&buffer) = false; buffer.buffer->stream = file; fprintf (file, "digraph RDG {\n"); for (i = 0; i < rdg->n_vertices; i++) { struct vertex *v = &(rdg->vertices[i]); struct graph_edge *e; fprintf (file, "%d [label=\"[%d] ", i, i); pp_gimple_stmt_1 (&buffer, RDGV_STMT (v), 0, TDF_SLIM); pp_flush (&buffer); fprintf (file, "\"]\n"); /* Highlight reads from memory. */ if (RDG_MEM_READS_STMT (rdg, i)) fprintf (file, "%d [style=filled, fillcolor=green]\n", i); /* Highlight stores to memory. */ if (RDG_MEM_WRITE_STMT (rdg, i)) fprintf (file, "%d [style=filled, fillcolor=red]\n", i); if (v->succ) for (e = v->succ; e; e = e->succ_next) switch (RDGE_TYPE (e)) { case flow_dd: /* These are the most common dependences: don't print these. */ fprintf (file, "%d -> %d \n", i, e->dest); break; case control_dd: fprintf (file, "%d -> %d [label=control] \n", i, e->dest); break; default: gcc_unreachable (); } } fprintf (file, "}\n\n"); }
static bool predecessor_has_mem_write (struct graph *rdg, struct vertex *v) { struct graph_edge *e; if (v->pred) for (e = v->pred; e; e = e->pred_next) if (bitmap_bit_p (upstream_mem_writes, e->src) /* Don't consider flow channels: a write to memory followed by a read from memory. These channels allow the split of the RDG in different partitions. */ && !RDG_MEM_WRITE_STMT (rdg, e->src)) return true; return false; }
static void dump_rdg_vertex (FILE *file, struct graph *rdg, int i) { struct vertex *v = &(rdg->vertices[i]); struct graph_edge *e; fprintf (file, "(vertex %d: (%s%s) (in:", i, RDG_MEM_WRITE_STMT (rdg, i) ? "w" : "", RDG_MEM_READS_STMT (rdg, i) ? "r" : ""); if (v->pred) for (e = v->pred; e; e = e->pred_next) fprintf (file, " %d", e->src); fprintf (file, ") (out:"); if (v->succ) for (e = v->succ; e; e = e->succ_next) fprintf (file, " %d", e->dest); fprintf (file, ")\n"); print_gimple_stmt (file, RDGV_STMT (v), 0, TDF_VOPS|TDF_MEMSYMS); fprintf (file, ")\n"); }