This is a collection of changes that cleanup PTA. Bootstrap and regtest pending on x86_64-unknown-linux-gnu.
Richard. 2013-03-18 Richard Biener <rguent...@suse.de> * tree-ssa-structalias.c (find): Use gcc_checking_assert. (unite): Likewise. (merge_node_constraints): Likewise. (build_succ_graph): Likewise. (valid_graph_edge): Inline into single caller. (unify_nodes): Likewise. Use bitmap_set_bit return value and cache varinfo. (scc_visit): Fix formatting and variable use. (do_sd_constraint): Use gcc_checking_assert. (do_ds_constraint): Likewise. (do_complex_constraint): Likewise. (condense_visit): Likewise. Cleanup. (dump_pred_graph): New function. (perform_var_substitution): Dump the pred-graph before variable substitution. (find_equivalent_node): Use gcc_checking_assert. (rewrite_constraints): Guard checking loop with ENABLE_CHECKING. Index: gcc/tree-ssa-structalias.c =================================================================== *** gcc/tree-ssa-structalias.c.orig 2013-03-07 16:47:53.000000000 +0100 --- gcc/tree-ssa-structalias.c 2013-03-18 12:41:57.475843339 +0100 *************** static constraint_graph_t graph; *** 581,587 **** static unsigned int find (unsigned int node) { ! gcc_assert (node < graph->size); if (graph->rep[node] != node) return graph->rep[node] = find (graph->rep[node]); return node; --- 581,587 ---- static unsigned int find (unsigned int node) { ! gcc_checking_assert (node < graph->size); if (graph->rep[node] != node) return graph->rep[node] = find (graph->rep[node]); return node; *************** find (unsigned int node) *** 595,601 **** static bool unite (unsigned int to, unsigned int from) { ! gcc_assert (to < graph->size && from < graph->size); if (to != from && graph->rep[from] != to) { graph->rep[from] = to; --- 595,601 ---- static bool unite (unsigned int to, unsigned int from) { ! gcc_checking_assert (to < graph->size && from < graph->size); if (to != from && graph->rep[from] != to) { graph->rep[from] = to; *************** merge_node_constraints (constraint_graph *** 1023,1029 **** unsigned int i; constraint_t c; ! gcc_assert (find (from) == to); /* Move all complex constraints from src node into to node */ FOR_EACH_VEC_ELT (graph->complex[from], i, c) --- 1023,1029 ---- unsigned int i; constraint_t c; ! gcc_checking_assert (find (from) == to); /* Move all complex constraints from src node into to node */ FOR_EACH_VEC_ELT (graph->complex[from], i, c) *************** add_graph_edge (constraint_graph_t graph *** 1143,1158 **** } - /* Return true if {DEST.SRC} is an existing graph edge in GRAPH. */ - - static bool - valid_graph_edge (constraint_graph_t graph, unsigned int src, - unsigned int dest) - { - return (graph->succs[dest] - && bitmap_bit_p (graph->succs[dest], src)); - } - /* Initialize the constraint graph structure to contain SIZE nodes. */ static void --- 1143,1148 ---- *************** build_succ_graph (void) *** 1319,1325 **** else if (rhs.type == ADDRESSOF) { /* x = &y */ ! gcc_assert (find (rhs.var) == rhs.var); bitmap_set_bit (get_varinfo (lhsvar)->solution, rhsvar); } else if (lhsvar > anything_id --- 1309,1315 ---- else if (rhs.type == ADDRESSOF) { /* x = &y */ ! gcc_checking_assert (find (rhs.var) == rhs.var); bitmap_set_bit (get_varinfo (lhsvar)->solution, rhsvar); } else if (lhsvar > anything_id *************** scc_visit (constraint_graph_t graph, str *** 1396,1409 **** if (!bitmap_bit_p (si->visited, w)) scc_visit (graph, si, w); - { - unsigned int t = find (w); - unsigned int nnode = find (n); - gcc_assert (nnode == n); ! if (si->dfs[t] < si->dfs[nnode]) ! si->dfs[n] = si->dfs[t]; ! } } /* See if any components have been identified. */ --- 1386,1396 ---- if (!bitmap_bit_p (si->visited, w)) scc_visit (graph, si, w); ! unsigned int t = find (w); ! gcc_checking_assert (find (n) == n); ! if (si->dfs[t] < si->dfs[n]) ! si->dfs[n] = si->dfs[t]; } /* See if any components have been identified. */ *************** static void *** 1458,1465 **** unify_nodes (constraint_graph_t graph, unsigned int to, unsigned int from, bool update_changed) { - gcc_assert (to != from && find (to) == to); if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Unifying %s to %s\n", get_varinfo (from)->name, --- 1445,1452 ---- unify_nodes (constraint_graph_t graph, unsigned int to, unsigned int from, bool update_changed) { + gcc_checking_assert (to != from && find (to) == to); if (dump_file && (dump_flags & TDF_DETAILS)) fprintf (dump_file, "Unifying %s to %s\n", get_varinfo (from)->name, *************** unify_nodes (constraint_graph_t graph, u *** 1477,1511 **** as changed, decrease the changed count. */ if (update_changed ! && bitmap_bit_p (changed, from)) ! { ! bitmap_clear_bit (changed, from); ! bitmap_set_bit (changed, to); ! } ! if (get_varinfo (from)->solution) { /* If the solution changes because of the merging, we need to mark the variable as changed. */ ! if (bitmap_ior_into (get_varinfo (to)->solution, ! get_varinfo (from)->solution)) { if (update_changed) bitmap_set_bit (changed, to); } ! BITMAP_FREE (get_varinfo (from)->solution); ! if (get_varinfo (from)->oldsolution) ! BITMAP_FREE (get_varinfo (from)->oldsolution); if (stats.iterations > 0 ! && get_varinfo (to)->oldsolution) ! BITMAP_FREE (get_varinfo (to)->oldsolution); ! } ! if (valid_graph_edge (graph, to, to)) ! { ! if (graph->succs[to]) ! bitmap_clear_bit (graph->succs[to], to); } } /* Information needed to compute the topological ordering of a graph. */ --- 1464,1493 ---- as changed, decrease the changed count. */ if (update_changed ! && bitmap_clear_bit (changed, from)) ! bitmap_set_bit (changed, to); ! varinfo_t fromvi = get_varinfo (from); ! if (fromvi->solution) { /* If the solution changes because of the merging, we need to mark the variable as changed. */ ! varinfo_t tovi = get_varinfo (to); ! if (bitmap_ior_into (tovi->solution, fromvi->solution)) { if (update_changed) bitmap_set_bit (changed, to); } ! BITMAP_FREE (fromvi->solution); ! if (fromvi->oldsolution) ! BITMAP_FREE (fromvi->oldsolution); if (stats.iterations > 0 ! && tovi->oldsolution) ! BITMAP_FREE (tovi->oldsolution); } + if (graph->succs[to]) + bitmap_clear_bit (graph->succs[to], to); } /* Information needed to compute the topological ordering of a graph. */ *************** do_sd_constraint (constraint_graph_t gra *** 1581,1587 **** HOST_WIDE_INT roffset = c->rhs.offset; /* Our IL does not allow this. */ ! gcc_assert (c->lhs.offset == 0); /* If the solution of Y contains anything it is good enough to transfer this to the LHS. */ --- 1563,1569 ---- HOST_WIDE_INT roffset = c->rhs.offset; /* Our IL does not allow this. */ ! gcc_checking_assert (c->lhs.offset == 0); /* If the solution of Y contains anything it is good enough to transfer this to the LHS. */ *************** do_ds_constraint (constraint_t c, bitmap *** 1668,1674 **** bool escaped_p = false; /* Our IL does not allow this. */ ! gcc_assert (c->rhs.offset == 0); /* If the solution of y contains ANYTHING simply use the ANYTHING solution. This avoids needlessly increasing the points-to sets. */ --- 1650,1656 ---- bool escaped_p = false; /* Our IL does not allow this. */ ! gcc_checking_assert (c->rhs.offset == 0); /* If the solution of y contains ANYTHING simply use the ANYTHING solution. This avoids needlessly increasing the points-to sets. */ *************** do_complex_constraint (constraint_graph_ *** 1782,1788 **** bitmap solution; bool flag = false; ! gcc_assert (c->rhs.type == SCALAR && c->lhs.type == SCALAR); solution = get_varinfo (c->rhs.var)->solution; tmp = get_varinfo (c->lhs.var)->solution; --- 1764,1770 ---- bitmap solution; bool flag = false; ! gcc_checking_assert (c->rhs.type == SCALAR && c->lhs.type == SCALAR); solution = get_varinfo (c->rhs.var)->solution; tmp = get_varinfo (c->lhs.var)->solution; *************** condense_visit (constraint_graph_t graph *** 1992,1998 **** bitmap_iterator bi; unsigned int my_dfs; ! gcc_assert (si->node_mapping[n] == n); bitmap_set_bit (si->visited, n); si->dfs[n] = si->current_index ++; my_dfs = si->dfs[n]; --- 1974,1980 ---- bitmap_iterator bi; unsigned int my_dfs; ! gcc_checking_assert (si->node_mapping[n] == n); bitmap_set_bit (si->visited, n); si->dfs[n] = si->current_index ++; my_dfs = si->dfs[n]; *************** condense_visit (constraint_graph_t graph *** 2007,2020 **** if (!bitmap_bit_p (si->visited, w)) condense_visit (graph, si, w); - { - unsigned int t = si->node_mapping[w]; - unsigned int nnode = si->node_mapping[n]; - gcc_assert (nnode == n); ! if (si->dfs[t] < si->dfs[nnode]) ! si->dfs[n] = si->dfs[t]; ! } } /* Visit all the implicit predecessors. */ --- 1989,1999 ---- if (!bitmap_bit_p (si->visited, w)) condense_visit (graph, si, w); ! unsigned int t = si->node_mapping[w]; ! gcc_checking_assert (si->node_mapping[n] == n); ! if (si->dfs[t] < si->dfs[n]) ! si->dfs[n] = si->dfs[t]; } /* Visit all the implicit predecessors. */ *************** condense_visit (constraint_graph_t graph *** 2027,2040 **** if (!bitmap_bit_p (si->visited, w)) condense_visit (graph, si, w); - { - unsigned int t = si->node_mapping[w]; - unsigned int nnode = si->node_mapping[n]; - gcc_assert (nnode == n); ! if (si->dfs[t] < si->dfs[nnode]) ! si->dfs[n] = si->dfs[t]; ! } } /* See if any components have been identified. */ --- 2006,2016 ---- if (!bitmap_bit_p (si->visited, w)) condense_visit (graph, si, w); ! unsigned int t = si->node_mapping[w]; ! gcc_assert (si->node_mapping[n] == n); ! if (si->dfs[t] < si->dfs[n]) ! si->dfs[n] = si->dfs[t]; } /* See if any components have been identified. */ *************** label_visit (constraint_graph_t graph, s *** 2164,2169 **** --- 2140,2214 ---- } } + /* Print the pred graph in dot format. */ + + static void + dump_pred_graph (struct scc_info *si, FILE *file) + { + unsigned int i; + + /* Only print the graph if it has already been initialized: */ + if (!graph) + return; + + /* Prints the header of the dot file: */ + fprintf (file, "strict digraph {\n"); + fprintf (file, " node [\n shape = box\n ]\n"); + fprintf (file, " edge [\n fontsize = \"12\"\n ]\n"); + fprintf (file, "\n // List of nodes and complex constraints in " + "the constraint graph:\n"); + + /* The next lines print the nodes in the graph together with the + complex constraints attached to them. */ + for (i = 0; i < graph->size; i++) + { + if (si->node_mapping[i] != i) + continue; + if (i < FIRST_REF_NODE) + fprintf (file, "\"%s\"", get_varinfo (i)->name); + else + fprintf (file, "\"*%s\"", get_varinfo (i - FIRST_REF_NODE)->name); + if (graph->points_to[i] + && !bitmap_empty_p (graph->points_to[i])) + { + fprintf (file, "[label=\"%s = {", get_varinfo (i)->name); + unsigned j; + bitmap_iterator bi; + EXECUTE_IF_SET_IN_BITMAP (graph->points_to[i], 0, j, bi) + fprintf (file, " %d", j); + fprintf (file, " }\"]"); + } + fprintf (file, ";\n"); + } + + /* Go over the edges. */ + fprintf (file, "\n // Edges in the constraint graph:\n"); + for (i = 0; i < graph->size; i++) + { + unsigned j; + bitmap_iterator bi; + if (si->node_mapping[i] != i) + continue; + EXECUTE_IF_IN_NONNULL_BITMAP (graph->preds[i], 0, j, bi) + { + unsigned from = si->node_mapping[j]; + if (from < FIRST_REF_NODE) + fprintf (file, "\"%s\"", get_varinfo (from)->name); + else + fprintf (file, "\"*%s\"", get_varinfo (from - FIRST_REF_NODE)->name); + fprintf (file, " -> "); + if (i < FIRST_REF_NODE) + fprintf (file, "\"%s\"", get_varinfo (i)->name); + else + fprintf (file, "\"*%s\"", get_varinfo (i - FIRST_REF_NODE)->name); + fprintf (file, ";\n"); + } + } + + /* Prints the tail of the dot file. */ + fprintf (file, "}\n"); + } + /* Perform offline variable substitution, discovering equivalence classes, and eliminating non-pointer variables. */ *************** perform_var_substitution (constraint_gra *** 2188,2193 **** --- 2233,2246 ---- if (!bitmap_bit_p (si->visited, si->node_mapping[i])) condense_visit (graph, si, si->node_mapping[i]); + if (dump_file && (dump_flags & TDF_GRAPH)) + { + fprintf (dump_file, "\n\n// The constraint graph before var-substitution " + "in dot format:\n"); + dump_pred_graph (si, dump_file); + fprintf (dump_file, "\n\n"); + } + bitmap_clear (si->visited); /* Actually the label the nodes for pointer equivalences */ for (i = 0; i < FIRST_REF_NODE; i++) *************** find_equivalent_node (constraint_graph_t *** 2303,2309 **** if (!bitmap_bit_p (graph->address_taken, node)) { ! gcc_assert (label < graph->size); if (graph->eq_rep[label] != -1) { --- 2356,2362 ---- if (!bitmap_bit_p (graph->address_taken, node)) { ! gcc_checking_assert (label < graph->size); if (graph->eq_rep[label] != -1) { *************** find_equivalent_node (constraint_graph_t *** 2320,2326 **** } else { ! gcc_assert (label < graph->size); graph->pe[node] = label; if (graph->pe_rep[label] == -1) graph->pe_rep[label] = node; --- 2373,2379 ---- } else { ! gcc_checking_assert (label < graph->size); graph->pe[node] = label; if (graph->pe_rep[label] == -1) graph->pe_rep[label] = node; *************** rewrite_constraints (constraint_graph_t *** 2400,2410 **** struct scc_info *si) { int i; - unsigned int j; constraint_t c; ! for (j = 0; j < graph->size; j++) gcc_assert (find (j) == j); FOR_EACH_VEC_ELT (constraints, i, c) { --- 2453,2464 ---- struct scc_info *si) { int i; constraint_t c; ! #ifdef ENABLE_CHECKING ! for (unsigned int j = 0; j < graph->size; j++) gcc_assert (find (j) == j); + #endif FOR_EACH_VEC_ELT (constraints, i, c) { *************** rewrite_constraints (constraint_graph_t *** 2456,2462 **** rhsvar = find_equivalent_node (graph, rhsvar, rhslabel); c->lhs.var = lhsvar; c->rhs.var = rhsvar; - } } --- 2510,2515 ----