diff options
Diffstat (limited to 'gcc/tree-tailcall.c')
-rw-r--r-- | gcc/tree-tailcall.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/gcc/tree-tailcall.c b/gcc/tree-tailcall.c index 6f3fdcaaf93..a6c44933f79 100644 --- a/gcc/tree-tailcall.c +++ b/gcc/tree-tailcall.c @@ -190,6 +190,7 @@ independent_of_stmt_p (tree expr, tree at, block_stmt_iterator bsi) { basic_block bb, call_bb, at_bb; edge e; + edge_iterator ei; if (is_gimple_min_invariant (expr)) return expr; @@ -200,7 +201,7 @@ independent_of_stmt_p (tree expr, tree at, block_stmt_iterator bsi) /* Mark the blocks in the chain leading to the end. */ at_bb = bb_for_stmt (at); call_bb = bb_for_stmt (bsi_stmt (bsi)); - for (bb = call_bb; bb != at_bb; bb = bb->succ->dest) + for (bb = call_bb; bb != at_bb; bb = EDGE_SUCC (bb, 0)->dest) bb->aux = &bb->aux; bb->aux = &bb->aux; @@ -230,7 +231,7 @@ independent_of_stmt_p (tree expr, tree at, block_stmt_iterator bsi) break; } - for (e = bb->pred; e; e = e->pred_next) + FOR_EACH_EDGE (e, ei, bb->preds) if (e->src->aux) break; gcc_assert (e); @@ -244,7 +245,7 @@ independent_of_stmt_p (tree expr, tree at, block_stmt_iterator bsi) } /* Unmark the blocks. */ - for (bb = call_bb; bb != at_bb; bb = bb->succ->dest) + for (bb = call_bb; bb != at_bb; bb = EDGE_SUCC (bb, 0)->dest) bb->aux = NULL; bb->aux = NULL; @@ -371,7 +372,7 @@ find_tail_calls (basic_block bb, struct tailcall **ret) basic_block abb; stmt_ann_t ann; - if (bb->succ->succ_next) + if (EDGE_COUNT (bb->succs) > 1) return; for (bsi = bsi_last (bb); !bsi_end_p (bsi); bsi_prev (&bsi)) @@ -412,8 +413,9 @@ find_tail_calls (basic_block bb, struct tailcall **ret) if (bsi_end_p (bsi)) { + edge_iterator ei; /* Recurse to the predecessors. */ - for (e = bb->pred; e; e = e->pred_next) + FOR_EACH_EDGE (e, ei, bb->preds) find_tail_calls (e->src, ret); return; @@ -458,8 +460,8 @@ find_tail_calls (basic_block bb, struct tailcall **ret) while (bsi_end_p (absi)) { - ass_var = propagate_through_phis (ass_var, abb->succ); - abb = abb->succ->dest; + ass_var = propagate_through_phis (ass_var, EDGE_SUCC (abb, 0)); + abb = EDGE_SUCC (abb, 0)->dest; absi = bsi_start (abb); } @@ -677,7 +679,7 @@ eliminate_tail_call (struct tailcall *t) if (TREE_CODE (stmt) == MODIFY_EXPR) stmt = TREE_OPERAND (stmt, 1); - first = ENTRY_BLOCK_PTR->succ->dest; + first = EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest; /* Remove the code after call_bsi that will become unreachable. The possibly unreachable code in other blocks is removed later in @@ -697,7 +699,7 @@ eliminate_tail_call (struct tailcall *t) } /* Replace the call by a jump to the start of function. */ - e = redirect_edge_and_branch (t->call_block->succ, first); + e = redirect_edge_and_branch (EDGE_SUCC (t->call_block, 0), first); gcc_assert (e); PENDING_STMT (e) = NULL_TREE; @@ -752,12 +754,12 @@ eliminate_tail_call (struct tailcall *t) var_ann (param)->default_def = new_name; phi = create_phi_node (name, first); SSA_NAME_DEF_STMT (name) = phi; - add_phi_arg (&phi, new_name, ENTRY_BLOCK_PTR->succ); + add_phi_arg (&phi, new_name, EDGE_SUCC (ENTRY_BLOCK_PTR, 0)); /* For all calls the same set of variables should be clobbered. This means that there always should be the appropriate phi node except for the first time we eliminate the call. */ - gcc_assert (!first->pred->pred_next->pred_next); + gcc_assert (EDGE_COUNT (first->preds) <= 2); } add_phi_arg (&phi, V_MAY_DEF_OP (v_may_defs, i), e); @@ -819,15 +821,16 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls) bool phis_constructed = false; struct tailcall *tailcalls = NULL, *act, *next; bool changed = false; - basic_block first = ENTRY_BLOCK_PTR->succ->dest; + basic_block first = EDGE_SUCC (ENTRY_BLOCK_PTR, 0)->dest; tree stmt, param, ret_type, tmp, phi; + edge_iterator ei; if (!suitable_for_tail_opt_p ()) return; if (opt_tailcalls) opt_tailcalls = suitable_for_tail_call_opt_p (); - for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next) + FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) { /* Only traverse the normal exits, i.e. those that end with return statement. */ @@ -848,8 +851,8 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls) if (!phis_constructed) { /* Ensure that there is only one predecessor of the block. */ - if (first->pred->pred_next) - first = split_edge (ENTRY_BLOCK_PTR->succ); + if (EDGE_COUNT (first->preds) > 1) + first = split_edge (EDGE_SUCC (ENTRY_BLOCK_PTR, 0)); /* Copy the args if needed. */ for (param = DECL_ARGUMENTS (current_function_decl); @@ -868,7 +871,7 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls) var_ann (param)->default_def = new_name; phi = create_phi_node (name, first); SSA_NAME_DEF_STMT (name) = phi; - add_phi_arg (&phi, new_name, first->pred); + add_phi_arg (&phi, new_name, EDGE_PRED (first, 0)); } phis_constructed = true; } @@ -881,7 +884,7 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls) add_referenced_tmp_var (tmp); phi = create_phi_node (tmp, first); - add_phi_arg (&phi, build_int_cst (ret_type, 0), first->pred); + add_phi_arg (&phi, build_int_cst (ret_type, 0), EDGE_PRED (first, 0)); a_acc = PHI_RESULT (phi); } @@ -893,7 +896,7 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls) add_referenced_tmp_var (tmp); phi = create_phi_node (tmp, first); - add_phi_arg (&phi, build_int_cst (ret_type, 1), first->pred); + add_phi_arg (&phi, build_int_cst (ret_type, 1), EDGE_PRED (first, 0)); m_acc = PHI_RESULT (phi); } } @@ -908,7 +911,7 @@ tree_optimize_tail_calls_1 (bool opt_tailcalls) if (a_acc || m_acc) { /* Modify the remaining return statements. */ - for (e = EXIT_BLOCK_PTR->pred; e; e = e->pred_next) + FOR_EACH_EDGE (e, ei, EXIT_BLOCK_PTR->preds) { stmt = last_stmt (e->src); |