diff options
author | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-17 02:31:56 +0000 |
---|---|---|
committer | rth <rth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2002-05-17 02:31:56 +0000 |
commit | b3d6de8978fd2208885e98b19a91c9d29c170af5 (patch) | |
tree | 94c8895c6dde3b282518d4c9951067cd0ac517fd /gcc/profile.c | |
parent | 5e7d465f337d9d419b2528ad819390067caeca95 (diff) | |
download | gcc-b3d6de8978fd2208885e98b19a91c9d29c170af5.tar.gz |
Revert "Basic block renumbering removal", and two followup patches.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@53537 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/profile.c')
-rw-r--r-- | gcc/profile.c | 99 |
1 files changed, 55 insertions, 44 deletions
diff --git a/gcc/profile.c b/gcc/profile.c index 73dbd0b79fe..60159a3e322 100644 --- a/gcc/profile.c +++ b/gcc/profile.c @@ -73,11 +73,11 @@ struct bb_info /* Keep all basic block indexes nonnegative in the gcov output. Index 0 is used for entry block, last block exit block. */ #define GCOV_INDEX_TO_BB(i) ((i) == 0 ? ENTRY_BLOCK_PTR \ - : (((i) == last_basic_block + 1) \ + : (((i) == n_basic_blocks + 1) \ ? EXIT_BLOCK_PTR : BASIC_BLOCK ((i)-1))) #define BB_TO_GCOV_INDEX(bb) ((bb) == ENTRY_BLOCK_PTR ? 0 \ : ((bb) == EXIT_BLOCK_PTR \ - ? last_basic_block + 1 : (bb)->sindex + 1)) + ? n_basic_blocks + 1 : (bb)->index + 1)) /* Instantiate the profile info structure. */ @@ -137,13 +137,14 @@ static void instrument_edges (el) struct edge_list *el; { + int i; int num_instr_edges = 0; int num_edges = NUM_EDGES (el); - basic_block bb; remove_fake_edges (); - FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) + for (i = 0; i < n_basic_blocks + 2; i++) { + basic_block bb = GCOV_INDEX_TO_BB (i); edge e = bb->succ; while (e) { @@ -154,7 +155,7 @@ instrument_edges (el) abort (); if (rtl_dump_file) fprintf (rtl_dump_file, "Edge %d to %d instrumented%s\n", - e->src->sindex, e->dest->sindex, + e->src->index, e->dest->index, EDGE_CRITICAL_P (e) ? " (and split)" : ""); need_func_profiler = 1; insert_insn_on_edge ( @@ -215,8 +216,8 @@ static gcov_type * get_exec_counts () { int num_edges = 0; - basic_block bb; - int okay = 1, j; + int i; + int okay = 1; int mismatch = 0; gcov_type *profile; char *function_name_buffer; @@ -232,12 +233,15 @@ get_exec_counts () /* Count the edges to be (possibly) instrumented. */ - FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) + for (i = 0; i < n_basic_blocks + 2; i++) { + basic_block bb = GCOV_INDEX_TO_BB (i); edge e; for (e = bb->succ; e; e = e->succ_next) if (!EDGE_INFO (e)->ignore && !EDGE_INFO (e)->on_tree) - num_edges++; + { + num_edges++; + } } /* now read and combine all matching profiles. */ @@ -247,8 +251,8 @@ get_exec_counts () function_name_buffer_len = strlen (current_function_name) + 1; function_name_buffer = xmalloc (function_name_buffer_len + 1); - for (j = 0; j < num_edges; j++) - profile[j] = 0; + for (i = 0; i < num_edges; i++) + profile[i] = 0; while (1) { @@ -372,8 +376,8 @@ get_exec_counts () static void compute_branch_probabilities () { - basic_block bb; - int num_edges = 0, i; + int i; + int num_edges = 0; int changes; int passes; int hist_br_prob[20]; @@ -385,8 +389,9 @@ compute_branch_probabilities () /* Attach extra info block to each bb. */ alloc_aux_for_blocks (sizeof (struct bb_info)); - FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) + for (i = 0; i < n_basic_blocks + 2; i++) { + basic_block bb = GCOV_INDEX_TO_BB (i); edge e; for (e = bb->succ; e; e = e->succ_next) @@ -407,8 +412,9 @@ compute_branch_probabilities () /* The first count in the .da file is the number of times that the function was entered. This is the exec_count for block zero. */ - FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) + for (i = 0; i < n_basic_blocks + 2; i++) { + basic_block bb = GCOV_INDEX_TO_BB (i); edge e; for (e = bb->succ; e; e = e->succ_next) if (!EDGE_INFO (e)->ignore && !EDGE_INFO (e)->on_tree) @@ -427,7 +433,7 @@ compute_branch_probabilities () if (rtl_dump_file) { fprintf (rtl_dump_file, "\nRead edge from %i to %i, count:", - bb->sindex, e->dest->sindex); + bb->index, e->dest->index); fprintf (rtl_dump_file, HOST_WIDEST_INT_PRINT_DEC, (HOST_WIDEST_INT) e->count); } @@ -460,8 +466,9 @@ compute_branch_probabilities () { passes++; changes = 0; - FOR_BB_BETWEEN (bb, EXIT_BLOCK_PTR, NULL, prev_bb) + for (i = n_basic_blocks + 1; i >= 0; i--) { + basic_block bb = GCOV_INDEX_TO_BB (i); struct bb_info *bi = BB_INFO (bb); if (! bi->count_valid) { @@ -556,8 +563,9 @@ compute_branch_probabilities () /* If the graph has been correctly solved, every block will have a succ and pred count of zero. */ - FOR_ALL_BB (bb) + for (i = 0; i < n_basic_blocks; i++) { + basic_block bb = BASIC_BLOCK (i); if (BB_INFO (bb)->succ_count || BB_INFO (bb)->pred_count) abort (); } @@ -570,8 +578,9 @@ compute_branch_probabilities () num_never_executed = 0; num_branches = 0; - FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) + for (i = 0; i <= n_basic_blocks + 1; i++) { + basic_block bb = GCOV_INDEX_TO_BB (i); edge e; gcov_type total; rtx note; @@ -585,11 +594,11 @@ compute_branch_probabilities () if (e->probability < 0 || e->probability > REG_BR_PROB_BASE) { error ("corrupted profile info: prob for %d-%d thought to be %d", - e->src->sindex, e->dest->sindex, e->probability); + e->src->index, e->dest->index, e->probability); e->probability = REG_BR_PROB_BASE / 2; } } - if (bb->sindex >= 0 + if (bb->index >= 0 && any_condjump_p (bb->end) && bb->succ->succ_next) { @@ -646,7 +655,7 @@ compute_branch_probabilities () for (e = bb->succ; e; e = e->succ_next) e->probability = REG_BR_PROB_BASE / total; } - if (bb->sindex >= 0 + if (bb->index >= 0 && any_condjump_p (bb->end) && bb->succ->succ_next) num_branches++, num_never_executed; @@ -687,10 +696,12 @@ static long compute_checksum () { long chsum = 0; - basic_block bb; + int i; - FOR_ALL_BB (bb) + + for (i = 0; i < n_basic_blocks ; i++) { + basic_block bb = BASIC_BLOCK (i); edge e; for (e = bb->succ; e; e = e->succ_next) @@ -723,7 +734,6 @@ compute_checksum () void branch_prob () { - basic_block bb; int i; int num_edges, ignored_edges; struct edge_list *el; @@ -752,10 +762,11 @@ branch_prob () We also add fake exit edges for each call and asm statement in the basic, since it may not return. */ - FOR_ALL_BB (bb) + for (i = 0; i < n_basic_blocks ; i++) { int need_exit_edge = 0, need_entry_edge = 0; int have_exit_edge = 0, have_entry_edge = 0; + basic_block bb = BASIC_BLOCK (i); rtx insn; edge e; @@ -780,7 +791,7 @@ branch_prob () { /* We should not get abort here, as call to setjmp should not be the very first instruction of function. */ - if (bb == ENTRY_BLOCK_PTR) + if (!i) abort (); make_edge (ENTRY_BLOCK_PTR, bb, EDGE_FAKE); } @@ -808,14 +819,14 @@ branch_prob () { if (rtl_dump_file) fprintf (rtl_dump_file, "Adding fake exit edge to bb %i\n", - bb->sindex); + bb->index); make_edge (bb, EXIT_BLOCK_PTR, EDGE_FAKE); } if (need_entry_edge && !have_entry_edge) { if (rtl_dump_file) fprintf (rtl_dump_file, "Adding fake entry edge to bb %i\n", - bb->sindex); + bb->index); make_edge (ENTRY_BLOCK_PTR, bb, EDGE_FAKE); } } @@ -847,10 +858,10 @@ branch_prob () GCOV utility. */ if (flag_test_coverage) { - basic_block bb; - - FOR_ALL_BB (bb) + int i = 0; + for (i = 0 ; i < n_basic_blocks; i++) { + basic_block bb = BASIC_BLOCK (i); rtx insn = bb->head; static int ignore_next_note = 0; @@ -928,9 +939,9 @@ branch_prob () } } - total_num_blocks += num_basic_blocks + 2; + total_num_blocks += n_basic_blocks + 2; if (rtl_dump_file) - fprintf (rtl_dump_file, "%d basic blocks\n", num_basic_blocks); + fprintf (rtl_dump_file, "%d basic blocks\n", n_basic_blocks); total_num_edges += num_edges; if (rtl_dump_file) @@ -956,11 +967,12 @@ branch_prob () __write_long (profile_info.current_function_cfg_checksum, bbg_file, 4); /* The plus 2 stands for entry and exit block. */ - __write_long (num_basic_blocks + 2, bbg_file, 4); + __write_long (n_basic_blocks + 2, bbg_file, 4); __write_long (num_edges - ignored_edges + 1, bbg_file, 4); - FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) + for (i = 0; i < n_basic_blocks + 1; i++) { + basic_block bb = GCOV_INDEX_TO_BB (i); edge e; long count = 0; @@ -1069,14 +1081,13 @@ find_spanning_tree (el) struct edge_list *el; { int i; - basic_block bb; int num_edges = NUM_EDGES (el); /* We use aux field for standard union-find algorithm. */ EXIT_BLOCK_PTR->aux = EXIT_BLOCK_PTR; ENTRY_BLOCK_PTR->aux = ENTRY_BLOCK_PTR; - FOR_ALL_BB (bb) - bb->aux = bb; + for (i = 0; i < n_basic_blocks; i++) + BASIC_BLOCK (i)->aux = BASIC_BLOCK (i); /* Add fake edge exit to entry we can't instrument. */ union_groups (EXIT_BLOCK_PTR, ENTRY_BLOCK_PTR); @@ -1095,7 +1106,7 @@ find_spanning_tree (el) { if (rtl_dump_file) fprintf (rtl_dump_file, "Abnormal edge %d to %d put to tree\n", - e->src->sindex, e->dest->sindex); + e->src->index, e->dest->index); EDGE_INFO (e)->on_tree = 1; union_groups (e->src, e->dest); } @@ -1111,7 +1122,7 @@ find_spanning_tree (el) { if (rtl_dump_file) fprintf (rtl_dump_file, "Critical edge %d to %d put to tree\n", - e->src->sindex, e->dest->sindex); + e->src->index, e->dest->index); EDGE_INFO (e)->on_tree = 1; union_groups (e->src, e->dest); } @@ -1126,7 +1137,7 @@ find_spanning_tree (el) { if (rtl_dump_file) fprintf (rtl_dump_file, "Normal edge %d to %d put to tree\n", - e->src->sindex, e->dest->sindex); + e->src->index, e->dest->index); EDGE_INFO (e)->on_tree = 1; union_groups (e->src, e->dest); } @@ -1134,8 +1145,8 @@ find_spanning_tree (el) EXIT_BLOCK_PTR->aux = NULL; ENTRY_BLOCK_PTR->aux = NULL; - FOR_ALL_BB (bb) - bb->aux = NULL; + for (i = 0; i < n_basic_blocks; i++) + BASIC_BLOCK (i)->aux = NULL; } /* Perform file-level initialization for branch-prob processing. */ |