diff options
author | rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-23 19:23:51 +0000 |
---|---|---|
committer | rakdver <rakdver@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-23 19:23:51 +0000 |
commit | 4c26117afc55fbf0b998d0bf25f1ab56da4dd180 (patch) | |
tree | d9ef360c452a150ca3f25a23e593846ce26b64f0 /gcc/cfganal.c | |
parent | df64d85ee58f6385c06511417a9a8a2f60a17261 (diff) | |
download | gcc-4c26117afc55fbf0b998d0bf25f1ab56da4dd180.tar.gz |
* bb-reorder.c (make_reorder_chain, make_reorder_chain_1):
Use FOR_EACH_BB macros to iterate over basic block chain.
* cfg.c (clear_edges, clear_bb_flags, dump_flow_info,
alloc_aux_for_blocks, clear_aux_for_blocks, alloc_aux_for_edges):
Likewise.
* cfganal.c (set_edge_can_fallthru_flag, flow_call_edges_add,
find_unreachable_blocks, create_edge_list, verify_edge_list,
remove_fake_edges, add_noreturn_fake_exit_edges,
flow_preorder_transversal_compute, flow_dfs_compute_reverse_execute):
Likewise.
* cfgbuild.c (make_edges, find_basic_blocks, find_many_sub_basic_blocks,
find_sub_basic_blocks): Likewise.
* cfgcleanup.c (try_optimize_cfg, delete_unreachable_blocks):
Likewise.
* cfglayout.c (record_effective_endpoints, cleanup_unconditional_jumps):
Likewise.
* cfgloop.c (flow_loops_cfg_dump, flow_loops_find):
Likewise.
* cfgrtl.c (compute_bb_for_insn, tidy_fallthru_edges,
commit_edge_insertions, commit_edge_insertions_watch_calls,
print_rtl_with_bb, verify_flow_info, purge_all_dead_edges): Likewise.
* combine.c (combine_instructions, reg_dead_at_p): Likewise.
* conflict.c (conflict_graph_compute): Likewise.
* df.c (df_bitmaps_alloc, df_bitmaps_free, df_alloc, df_analyse_1,
df_modified_p, df_refs_unlink, df_dump): Likewise.
* dominance.c (calc_dfs_tree, calculate_dominance_info): Likewise.
* final.c (compute_alignments): Likewise.
* flow.c (update_life_info, update_life_info_in_dirty_blocks,
delete_noop_moves, calculate_global_regs_live, allocate_bb_life_data,
count_or_remove_death_notes): Likewise.
* gcse.c (oprs_unchanged_p, record_last_reg_set_info,
compute_hash_table, compute_kill_rd, compute_rd, compute_ae_kill,
classic_gcse, compute_transp, cprop, compute_pre_data,
compute_transpout, invalidate_nonnull_info,
delete_null_pointer_checks_1, delete_null_pointer_checks,
compute_code_hoist_vbeinout, hoist_code, compute_ld_motion_mems,
compute_store_table, build_store_vectors, store_motion): Likewise.
* global.c (global_conflicts, mark_elimination): Likewise.
* graph.c (print_rtl_graph_with_bb): Likewise.
* haifa-sched.c (sched_init): Likewise.
* ifcvt.c (if_convert): Likewise.
* lcm.c (compute_antinout_edge, compute_laterin, compute_insert_delete,
compute_available, compute_nearerout, compute_rev_insert_delete,
optimize_mode_switching): Likewise.
* local-alloc.c (local_alloc, update_equiv_regs): Likewise.
* predict.c (estimate_probability, note_prediction_to_br_prob,
propagate_freq, counts_to_freqs, expensive_function_p,
estimate_bb_frequencies): Likewise.
* profile.c (instrument_edges, get_exec_counts,
compute_branch_probabilities, compute_checksum, branch_prob,
find_spanning_tree): Likewise.
* recog.c (split_all_insns, peephole2_optimize): Likewise.
* reg-stack.c (reg_to_stack, convert_regs_entry, convert_regs):
Likewise.
* regclass.c (scan_one_insn, regclass): Likewise.
* regmove.c (mark_flags_life_zones, regmove_optimize,
record_stack_memrefs): Likewise.
* regrename.c (regrename_optimize, copyprop_hardreg_forward): Likewise.
* reload1.c (reload, reload_combine, fixup_abnormal_edges): Likewise.
* resource.c (find_basic_block): Likewise.
* sched-ebb.c (schedule_ebbs): Likewise.
* sched-rgn.c (is_cfg_nonregular, build_control_flow,
find_single_block_region, find_rgns, schedule_insns)
* sibcall.c (optimize_sibling_and_tail_recursive_call)
* ssa-ccp.c (optimize_unexecutable_edges,
ssa_ccp_df_delete_unreachable_insns): Likewise.
* ssa-dce.c (ssa_eliminate_dead_code): Likewise.
* ssa.c (find_evaluations, compute_dominance_frontiers_1,
rename_block, convert_to_ssa, compute_conservative_reg_partition,
compute_coalesced_reg_partition, rename_equivalent_regs,
convert_from_ssa): Likewise.
* config/ia64/ia64.c (emit_predicate_relation_info, process_epilogue,
process_for_unwind_directive): Likewise.
* df.c (FOR_ALL_BBS): Removed.
* gcse.c (struct null_pointer_info): Type of current_block field
changed.
(struct reg_avail_info): Type of last_bb field changed.
* config/ia64/ia64.c (block_num): Removed.
(need_copy_state): Type changed.
(last_block): New.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53804 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cfganal.c')
-rw-r--r-- | gcc/cfganal.c | 183 |
1 files changed, 40 insertions, 143 deletions
diff --git a/gcc/cfganal.c b/gcc/cfganal.c index 570f6b3d5cd..71f54619763 100644 --- a/gcc/cfganal.c +++ b/gcc/cfganal.c @@ -194,10 +194,10 @@ mark_dfs_back_edges () void set_edge_can_fallthru_flag () { - int i; - for (i = 0; i < n_basic_blocks; i++) + basic_block bb; + + FOR_EACH_BB (bb) { - basic_block bb = BASIC_BLOCK (i); edge e; /* The FALLTHRU edge is also CAN_FALLTHRU edge. */ @@ -259,7 +259,7 @@ flow_call_edges_add (blocks) int i; int blocks_split = 0; int bb_num = 0; - basic_block *bbs; + basic_block *bbs, bb; bool check_last_block = false; /* Map bb indices into basic block pointers since split_block @@ -269,8 +269,8 @@ flow_call_edges_add (blocks) if (! blocks) { - for (i = 0; i < n_basic_blocks; i++) - bbs[bb_num++] = BASIC_BLOCK (i); + FOR_EACH_BB (bb) + bbs[bb_num++] = bb; check_last_block = true; } @@ -386,16 +386,15 @@ void find_unreachable_blocks () { edge e; - int i, n; - basic_block *tos, *worklist; + basic_block *tos, *worklist, bb; - n = n_basic_blocks; - tos = worklist = (basic_block *) xmalloc (sizeof (basic_block) * n); + tos = worklist = + (basic_block *) xmalloc (sizeof (basic_block) * n_basic_blocks); /* Clear all the reachability flags. */ - for (i = 0; i < n; ++i) - BASIC_BLOCK (i)->flags &= ~BB_REACHABLE; + FOR_EACH_BB (bb) + bb->flags &= ~BB_REACHABLE; /* Add our starting points to the worklist. Almost always there will be only one. It isn't inconceivable that we might one day directly @@ -445,8 +444,8 @@ create_edge_list () struct edge_list *elist; edge e; int num_edges; - int x; int block_count; + basic_block bb; block_count = n_basic_blocks + 2; /* Include the entry and exit blocks. */ @@ -454,18 +453,12 @@ create_edge_list () /* Determine the number of edges in the flow graph by counting successor edges on each basic block. */ - for (x = 0; x < n_basic_blocks; x++) + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb) { - basic_block bb = BASIC_BLOCK (x); - for (e = bb->succ; e; e = e->succ_next) num_edges++; } - /* Don't forget successors of the entry block. */ - for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next) - num_edges++; - elist = (struct edge_list *) xmalloc (sizeof (struct edge_list)); elist->num_blocks = block_count; elist->num_edges = num_edges; @@ -473,18 +466,10 @@ create_edge_list () num_edges = 0; - /* Follow successors of the entry block, and register these edges. */ - for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next) - elist->index_to_edge[num_edges++] = e; - - for (x = 0; x < n_basic_blocks; x++) - { - basic_block bb = BASIC_BLOCK (x); - - /* Follow all successors of blocks, and register these edges. */ - for (e = bb->succ; e; e = e->succ_next) - elist->index_to_edge[num_edges++] = e; - } + /* Follow successors of blocks, and register these edges. */ + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb) + for (e = bb->succ; e; e = e->succ_next) + elist->index_to_edge[num_edges++] = e; return elist; } @@ -538,13 +523,12 @@ verify_edge_list (f, elist) FILE *f; struct edge_list *elist; { - int x, pred, succ, index; + int pred, succ, index; edge e; + basic_block bb, p, s; - for (x = 0; x < n_basic_blocks; x++) + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb) { - basic_block bb = BASIC_BLOCK (x); - for (e = bb->succ; e; e = e->succ_next) { pred = e->src->index; @@ -565,33 +549,12 @@ verify_edge_list (f, elist) } } - for (e = ENTRY_BLOCK_PTR->succ; e; e = e->succ_next) - { - pred = e->src->index; - succ = e->dest->index; - index = EDGE_INDEX (elist, e->src, e->dest); - if (index == EDGE_INDEX_NO_EDGE) - { - fprintf (f, "*p* No index for edge from %d to %d\n", pred, succ); - continue; - } - - if (INDEX_EDGE_PRED_BB (elist, index)->index != pred) - fprintf (f, "*p* Pred for index %d should be %d not %d\n", - index, pred, INDEX_EDGE_PRED_BB (elist, index)->index); - if (INDEX_EDGE_SUCC_BB (elist, index)->index != succ) - fprintf (f, "*p* Succ for index %d should be %d not %d\n", - index, succ, INDEX_EDGE_SUCC_BB (elist, index)->index); - } - - /* We've verified that all the edges are in the list, no lets make sure + /* We've verified that all the edges are in the list, now lets make sure there are no spurious edges in the list. */ - for (pred = 0; pred < n_basic_blocks; pred++) - for (succ = 0; succ < n_basic_blocks; succ++) + FOR_BB_BETWEEN (p, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb) + FOR_BB_BETWEEN (s, ENTRY_BLOCK_PTR->next_bb, NULL, next_bb) { - basic_block p = BASIC_BLOCK (pred); - basic_block s = BASIC_BLOCK (succ); int found_edge = 0; for (e = p->succ; e; e = e->succ_next) @@ -608,78 +571,15 @@ verify_edge_list (f, elist) break; } - if (EDGE_INDEX (elist, BASIC_BLOCK (pred), BASIC_BLOCK (succ)) + if (EDGE_INDEX (elist, p, s) == EDGE_INDEX_NO_EDGE && found_edge != 0) fprintf (f, "*** Edge (%d, %d) appears to not have an index\n", - pred, succ); - if (EDGE_INDEX (elist, BASIC_BLOCK (pred), BASIC_BLOCK (succ)) + p->index, s->index); + if (EDGE_INDEX (elist, p, s) != EDGE_INDEX_NO_EDGE && found_edge == 0) fprintf (f, "*** Edge (%d, %d) has index %d, but there is no edge\n", - pred, succ, EDGE_INDEX (elist, BASIC_BLOCK (pred), - BASIC_BLOCK (succ))); + p->index, s->index, EDGE_INDEX (elist, p, s)); } - - for (succ = 0; succ < n_basic_blocks; succ++) - { - basic_block p = ENTRY_BLOCK_PTR; - basic_block s = BASIC_BLOCK (succ); - int found_edge = 0; - - for (e = p->succ; e; e = e->succ_next) - if (e->dest == s) - { - found_edge = 1; - break; - } - - for (e = s->pred; e; e = e->pred_next) - if (e->src == p) - { - found_edge = 1; - break; - } - - if (EDGE_INDEX (elist, ENTRY_BLOCK_PTR, BASIC_BLOCK (succ)) - == EDGE_INDEX_NO_EDGE && found_edge != 0) - fprintf (f, "*** Edge (entry, %d) appears to not have an index\n", - succ); - if (EDGE_INDEX (elist, ENTRY_BLOCK_PTR, BASIC_BLOCK (succ)) - != EDGE_INDEX_NO_EDGE && found_edge == 0) - fprintf (f, "*** Edge (entry, %d) has index %d, but no edge exists\n", - succ, EDGE_INDEX (elist, ENTRY_BLOCK_PTR, - BASIC_BLOCK (succ))); - } - - for (pred = 0; pred < n_basic_blocks; pred++) - { - basic_block p = BASIC_BLOCK (pred); - basic_block s = EXIT_BLOCK_PTR; - int found_edge = 0; - - for (e = p->succ; e; e = e->succ_next) - if (e->dest == s) - { - found_edge = 1; - break; - } - - for (e = s->pred; e; e = e->pred_next) - if (e->src == p) - { - found_edge = 1; - break; - } - - if (EDGE_INDEX (elist, BASIC_BLOCK (pred), EXIT_BLOCK_PTR) - == EDGE_INDEX_NO_EDGE && found_edge != 0) - fprintf (f, "*** Edge (%d, exit) appears to not have an index\n", - pred); - if (EDGE_INDEX (elist, BASIC_BLOCK (pred), EXIT_BLOCK_PTR) - != EDGE_INDEX_NO_EDGE && found_edge == 0) - fprintf (f, "*** Edge (%d, exit) has index %d, but no edge exists\n", - pred, EDGE_INDEX (elist, BASIC_BLOCK (pred), - EXIT_BLOCK_PTR)); - } } /* This routine will determine what, if any, edge there is between @@ -768,13 +668,10 @@ remove_fake_successors (bb) void remove_fake_edges () { - int x; - - for (x = 0; x < n_basic_blocks; x++) - remove_fake_successors (BASIC_BLOCK (x)); + basic_block bb; - /* We've handled all successors except the entry block's. */ - remove_fake_successors (ENTRY_BLOCK_PTR); + FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb) + remove_fake_successors (bb); } /* This function will add a fake edge between any block which has no @@ -784,11 +681,11 @@ remove_fake_edges () void add_noreturn_fake_exit_edges () { - int x; + basic_block bb; - for (x = 0; x < n_basic_blocks; x++) - if (BASIC_BLOCK (x)->succ == NULL) - make_single_succ_edge (BASIC_BLOCK (x), EXIT_BLOCK_PTR, EDGE_FAKE); + FOR_EACH_BB (bb) + if (bb->succ == NULL) + make_single_succ_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE); } /* This function adds a fake edge between any infinite loops to the @@ -1014,6 +911,7 @@ flow_preorder_transversal_compute (pot_order) sbitmap visited; struct dfst_node *node; struct dfst_node *dfst; + basic_block bb; /* Allocate stack for back-tracking up CFG. */ stack = (edge *) xmalloc ((n_basic_blocks + 1) * sizeof (edge)); @@ -1023,10 +921,10 @@ flow_preorder_transversal_compute (pot_order) dfst = (struct dfst_node *) xcalloc (n_basic_blocks, sizeof (struct dfst_node)); - for (i = 0; i < n_basic_blocks; i++) + FOR_EACH_BB (bb) { max_successors = 0; - for (e = BASIC_BLOCK (i)->succ; e; e = e->succ_next) + for (e = bb->succ; e; e = e->succ_next) max_successors++; dfst[i].node @@ -1183,7 +1081,6 @@ flow_dfs_compute_reverse_execute (data) { basic_block bb; edge e; - int i; while (data->sp > 0) { @@ -1197,9 +1094,9 @@ flow_dfs_compute_reverse_execute (data) } /* Determine if there are unvisited basic blocks. */ - for (i = n_basic_blocks - (INVALID_BLOCK + 1); --i >= 0; ) - if (!TEST_BIT (data->visited_blocks, i)) - return BASIC_BLOCK (i + (INVALID_BLOCK + 1)); + FOR_BB_BETWEEN (bb, EXIT_BLOCK_PTR, NULL, prev_bb) + if (!TEST_BIT (data->visited_blocks, bb->index - (INVALID_BLOCK + 1))) + return bb; return NULL; } |