diff options
author | matz <matz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-08 15:54:13 +0000 |
---|---|---|
committer | matz <matz@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-05-08 15:54:13 +0000 |
commit | 43e94e511c3a4b789ffc0a2e3ec0f93a0a12471c (patch) | |
tree | 6c299e917ec2a3f887c9fedcefdf3a151c51eebb /gcc/bb-reorder.c | |
parent | 126f07da205c51948b5c5f91a5738a4ac9a1d106 (diff) | |
download | gcc-43e94e511c3a4b789ffc0a2e3ec0f93a0a12471c.tar.gz |
* basic-block.h (struct rtl_bb_info): Remove visited member and
move head_ member to ...
(struct basic_block_def.basic_block_il_dependent): ... the new
member x, replacing but containing old member rtl.
(enum bb_flags): New BB_VISITED flag.
(BB_HEADER, BB_FOOTER): New macros.
* jump.c (mark_all_labels): Adjust.
* cfgcleanup.c (try_optimize_cfg): Adjust.
* cfglayout.c (record_effective_endpoints): Adjust.
(relink_block_chain): Ditto (and don't fiddle with visited).
(fixup_reorder_chain): Adjust.
(fixup_fallthru_exit_predecessor): Ditto.
(cfg_layout_duplicate_bb): Ditto.
* combine.c (update_cfg_for_uncondjump): Adjust.
* bb-reorder.c (struct bbro_basic_block_data_def): Add visited
member.
(bb_visited_trace): New accessor.
(mark_bb_visited): Move in front.
(rotate_loop): Use bb_visited_trace.
(find_traces_1_round): Ditto.
(emit_barrier_after): Ditto.
(copy_bb): Ditto, and initialize visited on resize.
(reorder_basic_blocks): Initize visited member.
(duplicate_computed_gotos): Clear bb flags at start, use
BB_VISITED flags.
* cfgrtl.c (try_redirect_by_replacing_jump): Adjust.
(rtl_verify_flow_info_1): Ditto.
(cfg_layout_split_block): Ditto.
(cfg_layout_delete_block): Ditto.
(cfg_layout_merge_blocks): Ditto.
(init_rtl_bb_info): Adjust and initialize il.x.head_ member.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187288 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/bb-reorder.c')
-rw-r--r-- | gcc/bb-reorder.c | 82 |
1 files changed, 49 insertions, 33 deletions
diff --git a/gcc/bb-reorder.c b/gcc/bb-reorder.c index c7f9c920d76..7f73b947e69 100644 --- a/gcc/bb-reorder.c +++ b/gcc/bb-reorder.c @@ -133,6 +133,9 @@ typedef struct bbro_basic_block_data_def /* Which trace is the bb in? */ int in_trace; + /* Which trace was this bb visited in? */ + int visited; + /* Which heap is BB in (if any)? */ fibheap_t heap; @@ -183,6 +186,29 @@ static void connect_traces (int, struct trace *); static bool copy_bb_p (const_basic_block, int); static bool push_to_next_round_p (const_basic_block, int, int, int, gcov_type); +/* Return the trace number in which BB was visited. */ + +static int +bb_visited_trace (const_basic_block bb) +{ + gcc_assert (bb->index < array_size); + return bbd[bb->index].visited; +} + +/* This function marks BB that it was visited in trace number TRACE. */ + +static void +mark_bb_visited (basic_block bb, int trace) +{ + bbd[bb->index].visited = trace; + if (bbd[bb->index].heap) + { + fibheap_delete_node (bbd[bb->index].heap, bbd[bb->index].node); + bbd[bb->index].heap = NULL; + bbd[bb->index].node = NULL; + } +} + /* Check to see if bb should be pushed into the next round of trace collections or not. Reasons for pushing the block forward are 1). If the block is cold, we are doing partitioning, and there will be @@ -306,14 +332,14 @@ rotate_loop (edge back_edge, struct trace *trace, int trace_n) FOR_EACH_EDGE (e, ei, bb->succs) if (e->dest != EXIT_BLOCK_PTR - && e->dest->il.rtl->visited != trace_n + && bb_visited_trace (e->dest) != trace_n && (e->flags & EDGE_CAN_FALLTHRU) && !(e->flags & EDGE_COMPLEX)) { if (is_preferred) { /* The best edge is preferred. */ - if (!e->dest->il.rtl->visited + if (!bb_visited_trace (e->dest) || bbd[e->dest->index].start_of_trace >= 0) { /* The current edge E is also preferred. */ @@ -329,7 +355,7 @@ rotate_loop (edge back_edge, struct trace *trace, int trace_n) } else { - if (!e->dest->il.rtl->visited + if (!bb_visited_trace (e->dest) || bbd[e->dest->index].start_of_trace >= 0) { /* The current edge E is preferred. */ @@ -397,20 +423,6 @@ rotate_loop (edge back_edge, struct trace *trace, int trace_n) return best_bb; } -/* This function marks BB that it was visited in trace number TRACE. */ - -static void -mark_bb_visited (basic_block bb, int trace) -{ - bb->il.rtl->visited = trace; - if (bbd[bb->index].heap) - { - fibheap_delete_node (bbd[bb->index].heap, bbd[bb->index].node); - bbd[bb->index].heap = NULL; - bbd[bb->index].node = NULL; - } -} - /* One round of finding traces. Find traces for BRANCH_TH and EXEC_TH i.e. do not include basic blocks their probability is lower than BRANCH_TH or their frequency is lower than EXEC_TH into traces (or count is lower than @@ -496,8 +508,8 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th, if (e->dest == EXIT_BLOCK_PTR) continue; - if (e->dest->il.rtl->visited - && e->dest->il.rtl->visited != *n_traces) + if (bb_visited_trace (e->dest) + && bb_visited_trace (e->dest) != *n_traces) continue; if (BB_PARTITION (e->dest) != BB_PARTITION (bb)) @@ -550,7 +562,7 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th, { if (e == best_edge || e->dest == EXIT_BLOCK_PTR - || e->dest->il.rtl->visited) + || bb_visited_trace (e->dest)) continue; key = bb_to_key (e->dest); @@ -611,7 +623,7 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th, if (best_edge) /* Suitable successor was found. */ { - if (best_edge->dest->il.rtl->visited == *n_traces) + if (bb_visited_trace (best_edge->dest) == *n_traces) { /* We do nothing with one basic block loops. */ if (best_edge->dest != bb) @@ -682,7 +694,7 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th, if (e != best_edge && (e->flags & EDGE_CAN_FALLTHRU) && !(e->flags & EDGE_COMPLEX) - && !e->dest->il.rtl->visited + && !bb_visited_trace (e->dest) && single_pred_p (e->dest) && !(e->flags & EDGE_CROSSING) && single_succ_p (e->dest) @@ -716,7 +728,7 @@ find_traces_1_round (int branch_th, int exec_th, gcov_type count_th, FOR_EACH_EDGE (e, ei, bb->succs) { if (e->dest == EXIT_BLOCK_PTR - || e->dest->il.rtl->visited) + || bb_visited_trace (e->dest)) continue; if (bbd[e->dest->index].heap) @@ -758,15 +770,11 @@ copy_bb (basic_block old_bb, edge e, basic_block bb, int trace) BB_COPY_PARTITION (new_bb, old_bb); gcc_assert (e->dest == new_bb); - gcc_assert (!e->dest->il.rtl->visited); if (dump_file) fprintf (dump_file, "Duplicated bb %d (created bb %d)\n", old_bb->index, new_bb->index); - new_bb->il.rtl->visited = trace; - new_bb->aux = bb->aux; - bb->aux = new_bb; if (new_bb->index >= array_size || last_basic_block > array_size) { @@ -779,8 +787,9 @@ copy_bb (basic_block old_bb, edge e, basic_block bb, int trace) for (i = array_size; i < new_size; i++) { bbd[i].start_of_trace = -1; - bbd[i].in_trace = -1; bbd[i].end_of_trace = -1; + bbd[i].in_trace = -1; + bbd[i].visited = 0; bbd[i].heap = NULL; bbd[i].node = NULL; } @@ -794,6 +803,11 @@ copy_bb (basic_block old_bb, edge e, basic_block bb, int trace) } } + gcc_assert (!bb_visited_trace (e->dest)); + mark_bb_visited (new_bb, trace); + new_bb->aux = bb->aux; + bb->aux = new_bb; + bbd[new_bb->index].in_trace = trace; return new_bb; @@ -1214,7 +1228,7 @@ static void emit_barrier_after_bb (basic_block bb) { rtx barrier = emit_barrier_after (BB_END (bb)); - bb->il.rtl->footer = unlink_insn_chain (barrier, barrier); + BB_FOOTER (bb) = unlink_insn_chain (barrier, barrier); } /* The landing pad OLD_LP, in block OLD_BB, has edges from both partitions. @@ -1929,8 +1943,9 @@ reorder_basic_blocks (void) for (i = 0; i < array_size; i++) { bbd[i].start_of_trace = -1; - bbd[i].in_trace = -1; bbd[i].end_of_trace = -1; + bbd[i].in_trace = -1; + bbd[i].visited = 0; bbd[i].heap = NULL; bbd[i].node = NULL; } @@ -2012,6 +2027,7 @@ duplicate_computed_gotos (void) if (n_basic_blocks <= NUM_FIXED_BLOCKS + 1) return 0; + clear_bb_flags (); cfg_layout_initialize (0); /* We are estimating the length of uncond jump insn only once @@ -2075,10 +2091,10 @@ duplicate_computed_gotos (void) /* Duplicate computed gotos. */ FOR_EACH_BB (bb) { - if (bb->il.rtl->visited) + if (bb->flags & BB_VISITED) continue; - bb->il.rtl->visited = 1; + bb->flags |= BB_VISITED; /* BB must have one outgoing edge. That edge must not lead to the exit block or the next block. @@ -2096,7 +2112,7 @@ duplicate_computed_gotos (void) new_bb = duplicate_block (single_succ (bb), single_succ_edge (bb), bb); new_bb->aux = bb->aux; bb->aux = new_bb; - new_bb->il.rtl->visited = 1; + new_bb->flags |= BB_VISITED; } done: |