aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c284
1 files changed, 148 insertions, 136 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 6f5284e..db0d1b5 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -441,7 +441,7 @@ make_edges (void)
/* Finally, if no edges were created above, this is a regular
basic block that only needs a fallthru edge. */
- if (bb->succ == NULL)
+ if (EDGE_COUNT (bb->succs) == 0)
make_edge (bb, bb->next_bb, EDGE_FALLTHRU);
}
@@ -483,7 +483,7 @@ make_ctrl_stmt_edges (basic_block bb)
case RESX_EXPR:
make_eh_edges (last);
/* Yet another NORETURN hack. */
- if (bb->succ == NULL)
+ if (EDGE_COUNT (bb->succs) == 0)
make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
break;
@@ -698,7 +698,7 @@ make_goto_expr_edges (basic_block bb)
}
/* Degenerate case of computed goto with no labels. */
- if (!for_call && !bb->succ)
+ if (!for_call && EDGE_COUNT (bb->succs) == 0)
make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE);
}
@@ -1009,20 +1009,19 @@ tree_can_merge_blocks_p (basic_block a, basic_block b)
tree stmt;
block_stmt_iterator bsi;
- if (!a->succ
- || a->succ->succ_next)
+ if (EDGE_COUNT (a->succs) != 1)
return false;
- if (a->succ->flags & EDGE_ABNORMAL)
+ if (EDGE_SUCC (a, 0)->flags & EDGE_ABNORMAL)
return false;
- if (a->succ->dest != b)
+ if (EDGE_SUCC (a, 0)->dest != b)
return false;
if (b == EXIT_BLOCK_PTR)
return false;
- if (b->pred->pred_next)
+ if (EDGE_COUNT (b->preds) > 1)
return false;
/* If A ends by a statement causing exceptions or something similar, we
@@ -1069,7 +1068,7 @@ tree_merge_blocks (basic_block a, basic_block b)
/* Ensure that B follows A. */
move_block_after (b, a);
- gcc_assert (a->succ->flags & EDGE_FALLTHRU);
+ gcc_assert (EDGE_SUCC (a, 0)->flags & EDGE_FALLTHRU);
gcc_assert (!last_stmt (a) || !stmt_ends_bb_p (last_stmt (a)));
/* Remove labels from B and set bb_for_stmt to A for other statements. */
@@ -1650,17 +1649,16 @@ cfg_remove_useless_stmts_bb (basic_block bb)
/* Check whether we come here from a condition, and if so, get the
condition. */
- if (!bb->pred
- || bb->pred->pred_next
- || !(bb->pred->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
+ if (EDGE_COUNT (bb->preds) != 1
+ || !(EDGE_PRED (bb, 0)->flags & (EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
return;
- cond = COND_EXPR_COND (last_stmt (bb->pred->src));
+ cond = COND_EXPR_COND (last_stmt (EDGE_PRED (bb, 0)->src));
if (TREE_CODE (cond) == VAR_DECL || TREE_CODE (cond) == PARM_DECL)
{
var = cond;
- val = (bb->pred->flags & EDGE_FALSE_VALUE
+ val = (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE
? boolean_false_node : boolean_true_node);
}
else if (TREE_CODE (cond) == TRUTH_NOT_EXPR
@@ -1668,12 +1666,12 @@ cfg_remove_useless_stmts_bb (basic_block bb)
|| TREE_CODE (TREE_OPERAND (cond, 0)) == PARM_DECL))
{
var = TREE_OPERAND (cond, 0);
- val = (bb->pred->flags & EDGE_FALSE_VALUE
+ val = (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE
? boolean_true_node : boolean_false_node);
}
else
{
- if (bb->pred->flags & EDGE_FALSE_VALUE)
+ if (EDGE_PRED (bb, 0)->flags & EDGE_FALSE_VALUE)
cond = invert_truthvalue (cond);
if (TREE_CODE (cond) == EQ_EXPR
&& (TREE_CODE (TREE_OPERAND (cond, 0)) == VAR_DECL
@@ -1776,8 +1774,8 @@ remove_phi_nodes_and_edges_for_unreachable_block (basic_block bb)
}
/* Remove edges to BB's successors. */
- while (bb->succ != NULL)
- ssa_remove_edge (bb->succ);
+ while (EDGE_COUNT (bb->succs) > 0)
+ ssa_remove_edge (EDGE_SUCC (bb, 0));
}
@@ -1859,12 +1857,11 @@ tree_block_forwards_to (basic_block bb)
single successor has phi nodes. */
if (bb == EXIT_BLOCK_PTR
|| bb == ENTRY_BLOCK_PTR
- || !bb->succ
- || bb->succ->succ_next
- || bb->succ->dest == EXIT_BLOCK_PTR
- || (bb->succ->flags & EDGE_ABNORMAL) != 0
+ || EDGE_COUNT (bb->succs) != 1
+ || EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR
+ || (EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL) != 0
|| phi_nodes (bb)
- || phi_nodes (bb->succ->dest))
+ || phi_nodes (EDGE_SUCC (bb, 0)->dest))
return NULL;
/* Walk past any labels at the start of this block. */
@@ -1882,11 +1879,11 @@ tree_block_forwards_to (basic_block bb)
edge dest;
/* Recursive call to pick up chains of forwarding blocks. */
- dest = tree_block_forwards_to (bb->succ->dest);
+ dest = tree_block_forwards_to (EDGE_SUCC (bb, 0)->dest);
- /* If none found, we forward to bb->succ at minimum. */
+ /* If none found, we forward to bb->succs[0] at minimum. */
if (!dest)
- dest = bb->succ;
+ dest = EDGE_SUCC (bb, 0);
ann->forwardable = 1;
return dest;
@@ -1933,9 +1930,10 @@ cleanup_control_expr_graph (basic_block bb, block_stmt_iterator bsi)
bool retval = false;
tree expr = bsi_stmt (bsi), val;
- if (bb->succ->succ_next)
+ if (EDGE_COUNT (bb->succs) > 1)
{
- edge e, next;
+ edge e;
+ edge_iterator ei;
switch (TREE_CODE (expr))
{
@@ -1958,9 +1956,8 @@ cleanup_control_expr_graph (basic_block bb, block_stmt_iterator bsi)
return false;
/* Remove all the edges except the one that is always executed. */
- for (e = bb->succ; e; e = next)
+ for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
{
- next = e->succ_next;
if (e != taken_edge)
{
taken_edge->probability += e->probability;
@@ -1968,12 +1965,14 @@ cleanup_control_expr_graph (basic_block bb, block_stmt_iterator bsi)
ssa_remove_edge (e);
retval = true;
}
+ else
+ ei_next (&ei);
}
if (taken_edge->probability > REG_BR_PROB_BASE)
taken_edge->probability = REG_BR_PROB_BASE;
}
else
- taken_edge = bb->succ;
+ taken_edge = EDGE_SUCC (bb, 0);
bsi_remove (&bsi);
taken_edge->flags = EDGE_FALLTHRU;
@@ -2016,7 +2015,7 @@ find_taken_edge (basic_block bb, tree val)
if (TREE_CODE (stmt) == SWITCH_EXPR)
return find_taken_edge_switch_expr (bb, val);
- return bb->succ;
+ return EDGE_SUCC (bb, 0);
}
@@ -2248,11 +2247,7 @@ dump_cfg_stats (FILE *file)
n_edges = 0;
FOR_EACH_BB (bb)
- {
- edge e;
- for (e = bb->succ; e; e = e->succ_next)
- n_edges++;
- }
+ n_edges += EDGE_COUNT (bb->succs);
size = n_edges * sizeof (struct edge_def);
total += size;
fprintf (file, fmt_str_1, "Edges", n_edges, SCALE (size), LABEL (size));
@@ -2294,6 +2289,7 @@ static void
tree_cfg2vcg (FILE *file)
{
edge e;
+ edge_iterator ei;
basic_block bb;
const char *funcname
= lang_hooks.decl_printable_name (current_function_decl, 2);
@@ -2304,7 +2300,7 @@ tree_cfg2vcg (FILE *file)
fprintf (file, "node: { title: \"EXIT\" label: \"EXIT\" }\n");
/* Write blocks and edges. */
- for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
{
fprintf (file, "edge: { sourcename: \"ENTRY\" targetname: \"%d\"",
e->dest->index);
@@ -2349,7 +2345,7 @@ tree_cfg2vcg (FILE *file)
bb->index, bb->index, head_name, head_line, end_name,
end_line);
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
{
if (e->dest == EXIT_BLOCK_PTR)
fprintf (file, "edge: { sourcename: \"%d\" targetname: \"EXIT\"", bb->index);
@@ -2497,6 +2493,7 @@ disband_implicit_edges (void)
basic_block bb;
block_stmt_iterator last;
edge e;
+ edge_iterator ei;
tree stmt, label;
FOR_EACH_BB (bb)
@@ -2510,7 +2507,7 @@ disband_implicit_edges (void)
from cfg_remove_useless_stmts here since it violates the
invariants for tree--cfg correspondence and thus fits better
here where we do it anyway. */
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
{
if (e->dest != bb->next_bb)
continue;
@@ -2531,15 +2528,14 @@ disband_implicit_edges (void)
{
/* Remove the RETURN_EXPR if we may fall though to the exit
instead. */
- gcc_assert (bb->succ);
- gcc_assert (!bb->succ->succ_next);
- gcc_assert (bb->succ->dest == EXIT_BLOCK_PTR);
+ gcc_assert (EDGE_COUNT (bb->succs) == 1);
+ gcc_assert (EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR);
if (bb->next_bb == EXIT_BLOCK_PTR
&& !TREE_OPERAND (stmt, 0))
{
bsi_remove (&last);
- bb->succ->flags |= EDGE_FALLTHRU;
+ EDGE_SUCC (bb, 0)->flags |= EDGE_FALLTHRU;
}
continue;
}
@@ -2550,7 +2546,7 @@ disband_implicit_edges (void)
continue;
/* Find a fallthru edge and emit the goto if necessary. */
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
if (e->flags & EDGE_FALLTHRU)
break;
@@ -2834,7 +2830,7 @@ tree_find_edge_insert_loc (edge e, block_stmt_iterator *bsi,
would have to examine the PHIs to prove that none of them used
the value set by the statement we want to insert on E. That
hardly seems worth the effort. */
- if (dest->pred->pred_next == NULL
+ if (EDGE_COUNT (dest->preds) == 1
&& ! phi_nodes (dest)
&& dest != EXIT_BLOCK_PTR)
{
@@ -2866,7 +2862,7 @@ tree_find_edge_insert_loc (edge e, block_stmt_iterator *bsi,
Except for the entry block. */
src = e->src;
if ((e->flags & EDGE_ABNORMAL) == 0
- && src->succ->succ_next == NULL
+ && EDGE_COUNT (src->succs) == 1
&& src != ENTRY_BLOCK_PTR)
{
*bsi = bsi_last (src);
@@ -2897,7 +2893,7 @@ tree_find_edge_insert_loc (edge e, block_stmt_iterator *bsi,
dest = split_edge (e);
if (new_bb)
*new_bb = dest;
- e = dest->pred;
+ e = EDGE_PRED (dest, 0);
goto restart;
}
@@ -2914,13 +2910,14 @@ bsi_commit_edge_inserts (int *new_blocks)
basic_block bb;
edge e;
int blocks;
+ edge_iterator ei;
blocks = n_basic_blocks;
- bsi_commit_edge_inserts_1 (ENTRY_BLOCK_PTR->succ);
+ bsi_commit_edge_inserts_1 (EDGE_SUCC (ENTRY_BLOCK_PTR, 0));
FOR_EACH_BB (bb)
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
bsi_commit_edge_inserts_1 (e);
if (new_blocks)
@@ -2990,6 +2987,7 @@ tree_split_edge (edge edge_in)
edge new_edge, e;
tree phi;
int i, num_elem;
+ edge_iterator ei;
/* Abnormal edges cannot be split. */
gcc_assert (!(edge_in->flags & EDGE_ABNORMAL));
@@ -3000,7 +2998,7 @@ tree_split_edge (edge edge_in)
/* Place the new block in the block list. Try to keep the new block
near its "logical" location. This is of most help to humans looking
at debugging dumps. */
- for (e = dest->pred; e; e = e->pred_next)
+ FOR_EACH_EDGE (e, ei, dest->preds)
if (e->src->next_bb == dest)
break;
if (!e)
@@ -3424,6 +3422,7 @@ tree_verify_flow_info (void)
block_stmt_iterator bsi;
tree stmt;
edge e;
+ edge_iterator ei;
if (ENTRY_BLOCK_PTR->stmt_list)
{
@@ -3437,7 +3436,7 @@ tree_verify_flow_info (void)
err = 1;
}
- for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next)
+ FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
if (e->flags & EDGE_FALLTHRU)
{
error ("Fallthru to exit from bb %d\n", e->src->index);
@@ -3503,7 +3502,7 @@ tree_verify_flow_info (void)
if (is_ctrl_stmt (stmt))
{
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
if (e->flags & EDGE_FALLTHRU)
{
error ("Fallthru edge after a control statement in bb %d \n",
@@ -3532,7 +3531,7 @@ tree_verify_flow_info (void)
|| !(false_edge->flags & EDGE_FALSE_VALUE)
|| (true_edge->flags & (EDGE_FALLTHRU | EDGE_ABNORMAL))
|| (false_edge->flags & (EDGE_FALLTHRU | EDGE_ABNORMAL))
- || bb->succ->succ_next->succ_next)
+ || EDGE_COUNT (bb->succs) >= 3)
{
error ("Wrong outgoing edge flags at end of bb %d\n",
bb->index);
@@ -3567,7 +3566,7 @@ tree_verify_flow_info (void)
{
/* FIXME. We should double check that the labels in the
destination blocks have their address taken. */
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
if ((e->flags & (EDGE_FALLTHRU | EDGE_TRUE_VALUE
| EDGE_FALSE_VALUE))
|| !(e->flags & EDGE_ABNORMAL))
@@ -3580,14 +3579,14 @@ tree_verify_flow_info (void)
break;
case RETURN_EXPR:
- if (!bb->succ || bb->succ->succ_next
- || (bb->succ->flags & (EDGE_FALLTHRU | EDGE_ABNORMAL
+ if (EDGE_COUNT (bb->succs) != 1
+ || (EDGE_SUCC (bb, 0)->flags & (EDGE_FALLTHRU | EDGE_ABNORMAL
| EDGE_TRUE_VALUE | EDGE_FALSE_VALUE)))
{
error ("Wrong outgoing edge flags at end of bb %d\n", bb->index);
err = 1;
}
- if (bb->succ->dest != EXIT_BLOCK_PTR)
+ if (EDGE_SUCC (bb, 0)->dest != EXIT_BLOCK_PTR)
{
error ("Return edge does not point to exit in bb %d\n",
bb->index);
@@ -3643,7 +3642,7 @@ tree_verify_flow_info (void)
err = 1;
}
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
{
if (!e->dest->aux)
{
@@ -3675,7 +3674,7 @@ tree_verify_flow_info (void)
}
}
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
e->dest->aux = (void *)0;
}
@@ -3697,13 +3696,14 @@ static void
tree_make_forwarder_block (edge fallthru)
{
edge e;
+ edge_iterator ei;
basic_block dummy, bb;
tree phi, new_phi, var, prev, next;
dummy = fallthru->src;
bb = fallthru->dest;
- if (!bb->pred->pred_next)
+ if (EDGE_COUNT (bb->preds) == 1)
return;
/* If we redirected a branch we must create new phi nodes at the
@@ -3728,7 +3728,7 @@ tree_make_forwarder_block (edge fallthru)
set_phi_nodes (bb, prev);
/* Add the arguments we have stored on edges. */
- for (e = bb->pred; e; e = e->pred_next)
+ FOR_EACH_EDGE (e, ei, bb->preds)
{
if (e == fallthru)
continue;
@@ -3752,6 +3752,7 @@ tree_forwarder_block_p (basic_block bb)
{
block_stmt_iterator bsi;
edge e;
+ edge_iterator ei;
/* If we have already determined that this block is not forwardable,
then no further checks are necessary. */
@@ -3760,10 +3761,9 @@ tree_forwarder_block_p (basic_block bb)
/* BB must have a single outgoing normal edge. Otherwise it can not be
a forwarder block. */
- if (!bb->succ
- || bb->succ->succ_next
- || bb->succ->dest == EXIT_BLOCK_PTR
- || (bb->succ->flags & EDGE_ABNORMAL)
+ if (EDGE_COUNT (bb->succs) != 1
+ || EDGE_SUCC (bb, 0)->dest == EXIT_BLOCK_PTR
+ || (EDGE_SUCC (bb, 0)->flags & EDGE_ABNORMAL)
|| bb == ENTRY_BLOCK_PTR)
{
bb_ann (bb)->forwardable = 0;
@@ -3771,7 +3771,7 @@ tree_forwarder_block_p (basic_block bb)
}
/* Successors of the entry block are not forwarders. */
- for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, ENTRY_BLOCK_PTR->succs)
if (e->dest == bb)
{
bb_ann (bb)->forwardable = 0;
@@ -3818,9 +3818,9 @@ tree_forwarder_block_p (basic_block bb)
static bool
thread_jumps (void)
{
- edge e, next, last, old;
+ edge e, last, old;
basic_block bb, dest, tmp, old_dest, curr, dom;
- tree phi;
+ tree phi;
int arg;
bool retval = false;
@@ -3829,8 +3829,10 @@ thread_jumps (void)
FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
{
+ edge_iterator ei;
+
/* Don't waste time on unreachable blocks. */
- if (!bb->pred)
+ if (EDGE_COUNT (bb->preds) == 0)
continue;
/* Nor on forwarders. */
@@ -3844,17 +3846,19 @@ thread_jumps (void)
/* Examine each of our block's successors to see if it is
forwardable. */
- for (e = bb->succ; e; e = next)
+ for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
{
int freq;
gcov_type count;
- next = e->succ_next;
/* If the edge is abnormal or its destination is not
forwardable, then there's nothing to do. */
if ((e->flags & EDGE_ABNORMAL)
|| !tree_forwarder_block_p (e->dest))
- continue;
+ {
+ ei_next (&ei);
+ continue;
+ }
count = e->count;
freq = EDGE_FREQUENCY (e);
@@ -3862,19 +3866,19 @@ thread_jumps (void)
/* Now walk through as many forwarder block as possible to
find the ultimate destination we want to thread our jump
to. */
- last = e->dest->succ;
+ last = EDGE_SUCC (e->dest, 0);
bb_ann (e->dest)->forwardable = 0;
- for (dest = e->dest->succ->dest;
+ for (dest = EDGE_SUCC (e->dest, 0)->dest;
tree_forwarder_block_p (dest);
- last = dest->succ,
- dest = dest->succ->dest)
+ last = EDGE_SUCC (dest, 0),
+ dest = EDGE_SUCC (dest, 0)->dest)
{
/* An infinite loop detected. We redirect the edge anyway, so
that the loop is shrunk into single basic block. */
if (!bb_ann (dest)->forwardable)
break;
- if (dest->succ->dest == EXIT_BLOCK_PTR)
+ if (EDGE_SUCC (dest, 0)->dest == EXIT_BLOCK_PTR)
break;
bb_ann (dest)->forwardable = 0;
@@ -3883,11 +3887,14 @@ thread_jumps (void)
/* Reset the forwardable marks to 1. */
for (tmp = e->dest;
tmp != dest;
- tmp = tmp->succ->dest)
+ tmp = EDGE_SUCC (tmp, 0)->dest)
bb_ann (tmp)->forwardable = 1;
if (dest == e->dest)
- continue;
+ {
+ ei_next (&ei);
+ continue;
+ }
old = find_edge (bb, dest);
if (old)
@@ -3903,7 +3910,10 @@ thread_jumps (void)
/* That might mean that no forwarding at all is possible. */
if (dest == e->dest)
- continue;
+ {
+ ei_next (&ei);
+ continue;
+ }
old = find_edge (bb, dest);
}
@@ -3916,7 +3926,7 @@ thread_jumps (void)
/* Update the profile. */
if (profile_status != PROFILE_ABSENT)
- for (curr = old_dest; curr != dest; curr = curr->succ->dest)
+ for (curr = old_dest; curr != dest; curr = EDGE_SUCC (curr, 0)->dest)
{
curr->frequency -= freq;
if (curr->frequency < 0)
@@ -3924,9 +3934,9 @@ thread_jumps (void)
curr->count -= count;
if (curr->count < 0)
curr->count = 0;
- curr->succ->count -= count;
- if (curr->succ->count < 0)
- curr->succ->count = 0;
+ EDGE_SUCC (curr, 0)->count -= count;
+ if (EDGE_SUCC (curr, 0)->count < 0)
+ EDGE_SUCC (curr, 0)->count = 0;
}
if (!old)
@@ -3951,9 +3961,9 @@ thread_jumps (void)
become unreachable). */
for (; old_dest != dest; old_dest = tmp)
{
- tmp = old_dest->succ->dest;
+ tmp = EDGE_SUCC (old_dest, 0)->dest;
- if (old_dest->pred)
+ if (EDGE_COUNT (old_dest->preds) > 0)
break;
delete_basic_block (old_dest);
@@ -3974,7 +3984,7 @@ thread_jumps (void)
for (; old_dest != dest; old_dest = tmp)
{
- tmp = old_dest->succ->dest;
+ tmp = EDGE_SUCC (old_dest, 0)->dest;
if (get_immediate_dominator (CDI_DOMINATORS, tmp) == old_dest
&& !dominated_by_p (CDI_DOMINATORS, bb, tmp))
@@ -4042,9 +4052,10 @@ tree_try_redirect_by_replacing_jump (edge e, basic_block target)
edge tmp;
block_stmt_iterator b;
tree stmt;
+ edge_iterator ei;
/* Verify that all targets will be TARGET. */
- for (tmp = src->succ; tmp; tmp = tmp->succ_next)
+ FOR_EACH_EDGE (tmp, ei, src->succs)
if (tmp->dest != target && tmp != e)
break;
@@ -4166,13 +4177,14 @@ tree_split_block (basic_block bb, void *stmt)
tree act;
basic_block new_bb;
edge e;
+ edge_iterator ei;
new_bb = create_empty_bb (bb);
/* Redirect the outgoing edges. */
- new_bb->succ = bb->succ;
- bb->succ = NULL;
- for (e = new_bb->succ; e; e = e->succ_next)
+ new_bb->succs = bb->succs;
+ bb->succs = NULL;
+ FOR_EACH_EDGE (e, ei, new_bb->succs)
e->src = new_bb;
if (stmt && TREE_CODE ((tree) stmt) == LABEL_EXPR)
@@ -4289,11 +4301,12 @@ add_phi_args_after_copy_bb (basic_block bb_copy)
{
basic_block bb, dest;
edge e, e_copy;
+ edge_iterator ei;
tree phi, phi_copy, phi_next, def;
bb = bb_copy->rbi->original;
- for (e_copy = bb_copy->succ; e_copy; e_copy = e_copy->succ_next)
+ FOR_EACH_EDGE (e_copy, ei, bb_copy->succs)
{
if (!phi_nodes (e_copy->dest))
continue;
@@ -4309,7 +4322,7 @@ add_phi_args_after_copy_bb (basic_block bb_copy)
/* During loop unrolling the target of the latch edge is copied.
In this case we are not looking for edge to dest, but to
duplicated block whose original was dest. */
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
if (e->dest->rbi->duplicated
&& e->dest->rbi->original == dest)
break;
@@ -4453,6 +4466,7 @@ rewrite_to_new_ssa_names_bb (basic_block bb, htab_t map)
{
unsigned i;
edge e;
+ edge_iterator ei;
tree phi, stmt;
block_stmt_iterator bsi;
use_optype uses;
@@ -4462,7 +4476,7 @@ rewrite_to_new_ssa_names_bb (basic_block bb, htab_t map)
v_must_def_optype v_must_defs;
stmt_ann_t ann;
- for (e = bb->pred; e; e = e->pred_next)
+ FOR_EACH_EDGE (e, ei, bb->preds)
if (e->flags & EDGE_ABNORMAL)
break;
@@ -4506,7 +4520,7 @@ rewrite_to_new_ssa_names_bb (basic_block bb, htab_t map)
(V_MUST_DEF_OP_PTR (v_must_defs, i), stmt, map);
}
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
for (phi = phi_nodes (e->dest); phi; phi = TREE_CHAIN (phi))
{
rewrite_to_new_ssa_names_use
@@ -4771,43 +4785,33 @@ dump_function_to_file (tree fn, FILE *file, int flags)
/* Pretty print of the loops intermediate representation. */
static void print_loop (FILE *, struct loop *, int);
-static void print_pred_bbs (FILE *, edge);
-static void print_succ_bbs (FILE *, edge);
+static void print_pred_bbs (FILE *, basic_block bb);
+static void print_succ_bbs (FILE *, basic_block bb);
/* Print the predecessors indexes of edge E on FILE. */
static void
-print_pred_bbs (FILE *file, edge e)
+print_pred_bbs (FILE *file, basic_block bb)
{
- if (e == NULL)
- return;
-
- else if (e->pred_next == NULL)
+ edge e;
+ edge_iterator ei;
+
+ FOR_EACH_EDGE (e, ei, bb->preds)
fprintf (file, "bb_%d", e->src->index);
-
- else
- {
- fprintf (file, "bb_%d, ", e->src->index);
- print_pred_bbs (file, e->pred_next);
- }
}
/* Print the successors indexes of edge E on FILE. */
static void
-print_succ_bbs (FILE *file, edge e)
+print_succ_bbs (FILE *file, basic_block bb)
{
- if (e == NULL)
- return;
- else if (e->succ_next == NULL)
- fprintf (file, "bb_%d", e->dest->index);
- else
- {
- fprintf (file, "bb_%d, ", e->dest->index);
- print_succ_bbs (file, e->succ_next);
- }
+ edge e;
+ edge_iterator ei;
+
+ FOR_EACH_EDGE (e, ei, bb->succs)
+ fprintf (file, "bb_%d", e->src->index);
}
@@ -4836,9 +4840,9 @@ print_loop (FILE *file, struct loop *loop, int indent)
{
/* Print the basic_block's header. */
fprintf (file, "%s bb_%d (preds = {", s_indent, bb->index);
- print_pred_bbs (file, bb->pred);
+ print_pred_bbs (file, bb);
fprintf (file, "}, succs = {");
- print_succ_bbs (file, bb->succ);
+ print_succ_bbs (file, bb);
fprintf (file, "})\n");
/* Print the basic_block's body. */
@@ -4966,6 +4970,7 @@ tree_flow_call_edges_add (sbitmap blocks)
Handle this by adding a dummy instruction in a new last basic block. */
if (check_last_block)
{
+ edge_iterator ei;
basic_block bb = EXIT_BLOCK_PTR->prev_bb;
block_stmt_iterator bsi = bsi_last (bb);
tree t = NULL_TREE;
@@ -4976,7 +4981,7 @@ tree_flow_call_edges_add (sbitmap blocks)
{
edge e;
- for (e = bb->succ; e; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
if (e->dest == EXIT_BLOCK_PTR)
{
bsi_insert_on_edge (e, build_empty_stmt ());
@@ -5018,8 +5023,11 @@ tree_flow_call_edges_add (sbitmap blocks)
mark that edge as fake and remove it later. */
#ifdef ENABLE_CHECKING
if (stmt == last_stmt)
- for (e = bb->succ; e; e = e->succ_next)
- gcc_assert (e->dest != EXIT_BLOCK_PTR);
+ {
+ edge_iterator ei;
+ FOR_EACH_EDGE (e, ei, bb->succs)
+ gcc_assert (e->dest != EXIT_BLOCK_PTR);
+ }
#endif
/* Note that the following may create a new basic block
@@ -5048,20 +5056,22 @@ bool
tree_purge_dead_eh_edges (basic_block bb)
{
bool changed = false;
- edge e, next;
+ edge e;
+ edge_iterator ei;
tree stmt = last_stmt (bb);
if (stmt && tree_can_throw_internal (stmt))
return false;
- for (e = bb->succ; e ; e = next)
+ for (ei = ei_start (bb->succs); (e = ei_safe_edge (ei)); )
{
- next = e->succ_next;
if (e->flags & EDGE_EH)
{
ssa_remove_edge (e);
changed = true;
}
+ else
+ ei_next (&ei);
}
return changed;
@@ -5114,10 +5124,11 @@ split_critical_edges (void)
{
basic_block bb;
edge e;
+ edge_iterator ei;
FOR_ALL_BB (bb)
{
- for (e = bb->succ; e ; e = e->succ_next)
+ FOR_EACH_EDGE (e, ei, bb->succs)
if (EDGE_CRITICAL_P (e) && !(e->flags & EDGE_ABNORMAL))
{
split_edge (e);
@@ -5227,10 +5238,11 @@ execute_warn_function_return (void)
#endif
tree last;
edge e;
+ edge_iterator ei;
if (warn_missing_noreturn
&& !TREE_THIS_VOLATILE (cfun->decl)
- && EXIT_BLOCK_PTR->pred == NULL
+ && EDGE_COUNT (EXIT_BLOCK_PTR->preds) == 0
&& !lang_hooks.function.missing_noreturn_ok_p (cfun->decl))
warning ("%Jfunction might be possible candidate for "
"attribute %<noreturn%>",
@@ -5238,14 +5250,14 @@ execute_warn_function_return (void)
/* If we have a path to EXIT, then we do return. */
if (TREE_THIS_VOLATILE (cfun->decl)
- && EXIT_BLOCK_PTR->pred != NULL)
+ && EDGE_COUNT (EXIT_BLOCK_PTR->preds) > 0)
{
#ifdef USE_MAPPED_LOCATION
location = UNKNOWN_LOCATION;
#else
locus = NULL;
#endif
- for (e = EXIT_BLOCK_PTR->pred; e ; e = e->pred_next)
+ FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
{
last = last_stmt (e->src);
if (TREE_CODE (last) == RETURN_EXPR
@@ -5270,10 +5282,10 @@ execute_warn_function_return (void)
/* If we see "return;" in some basic block, then we do reach the end
without returning a value. */
else if (warn_return_type
- && EXIT_BLOCK_PTR->pred != NULL
+ && EDGE_COUNT (EXIT_BLOCK_PTR->preds) > 0
&& !VOID_TYPE_P (TREE_TYPE (TREE_TYPE (cfun->decl))))
{
- for (e = EXIT_BLOCK_PTR->pred; e ; e = e->pred_next)
+ FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds)
{
tree last = last_stmt (e->src);
if (TREE_CODE (last) == RETURN_EXPR
@@ -5307,17 +5319,17 @@ extract_true_false_edges_from_block (basic_block b,
edge *true_edge,
edge *false_edge)
{
- edge e = b->succ;
+ edge e = EDGE_SUCC (b, 0);
if (e->flags & EDGE_TRUE_VALUE)
{
*true_edge = e;
- *false_edge = e->succ_next;
+ *false_edge = EDGE_SUCC (b, 1);
}
else
{
*false_edge = e;
- *true_edge = e->succ_next;
+ *true_edge = EDGE_SUCC (b, 1);
}
}