aboutsummaryrefslogtreecommitdiff
path: root/gcc/profile.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/profile.c')
-rw-r--r--gcc/profile.c64
1 files changed, 24 insertions, 40 deletions
diff --git a/gcc/profile.c b/gcc/profile.c
index 5924e0c..10f2afb 100644
--- a/gcc/profile.c
+++ b/gcc/profile.c
@@ -137,14 +137,13 @@ 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 (i = 0; i < n_basic_blocks + 2; i++)
+ FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
{
- basic_block bb = GCOV_INDEX_TO_BB (i);
edge e = bb->succ;
while (e)
{
@@ -216,8 +215,8 @@ static gcov_type *
get_exec_counts ()
{
int num_edges = 0;
- int i;
- int okay = 1;
+ basic_block bb;
+ int okay = 1, i;
int mismatch = 0;
gcov_type *profile;
char *function_name_buffer;
@@ -233,15 +232,12 @@ get_exec_counts ()
/* Count the edges to be (possibly) instrumented. */
- for (i = 0; i < n_basic_blocks + 2; i++)
+ FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
{
- 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. */
@@ -382,6 +378,7 @@ get_exec_counts ()
static void
compute_branch_probabilities ()
{
+ basic_block bb;
int i;
int num_edges = 0;
int changes;
@@ -395,9 +392,8 @@ compute_branch_probabilities ()
/* Attach extra info block to each bb. */
alloc_aux_for_blocks (sizeof (struct bb_info));
- for (i = 0; i < n_basic_blocks + 2; i++)
+ FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
{
- basic_block bb = GCOV_INDEX_TO_BB (i);
edge e;
for (e = bb->succ; e; e = e->succ_next)
@@ -418,9 +414,8 @@ 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 (i = 0; i < n_basic_blocks + 2; i++)
+ FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
{
- 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)
@@ -472,9 +467,8 @@ compute_branch_probabilities ()
{
passes++;
changes = 0;
- for (i = n_basic_blocks + 1; i >= 0; i--)
+ FOR_BB_BETWEEN (bb, EXIT_BLOCK_PTR, NULL, prev_bb)
{
- basic_block bb = GCOV_INDEX_TO_BB (i);
struct bb_info *bi = BB_INFO (bb);
if (! bi->count_valid)
{
@@ -569,9 +563,8 @@ compute_branch_probabilities ()
/* If the graph has been correctly solved, every block will have a
succ and pred count of zero. */
- for (i = 0; i < n_basic_blocks; i++)
+ FOR_EACH_BB (bb)
{
- basic_block bb = BASIC_BLOCK (i);
if (BB_INFO (bb)->succ_count || BB_INFO (bb)->pred_count)
abort ();
}
@@ -584,9 +577,8 @@ compute_branch_probabilities ()
num_never_executed = 0;
num_branches = 0;
- for (i = 0; i <= n_basic_blocks + 1; i++)
+ FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
{
- basic_block bb = GCOV_INDEX_TO_BB (i);
edge e;
gcov_type total;
rtx note;
@@ -702,12 +694,10 @@ static long
compute_checksum ()
{
long chsum = 0;
- int i;
-
+ basic_block bb;
- for (i = 0; i < n_basic_blocks ; i++)
+ FOR_EACH_BB (bb)
{
- basic_block bb = BASIC_BLOCK (i);
edge e;
for (e = bb->succ; e; e = e->succ_next)
@@ -740,6 +730,7 @@ compute_checksum ()
void
branch_prob ()
{
+ basic_block bb;
int i;
int num_edges, ignored_edges;
struct edge_list *el;
@@ -768,11 +759,10 @@ branch_prob ()
We also add fake exit edges for each call and asm statement in the
basic, since it may not return. */
- for (i = 0; i < n_basic_blocks ; i++)
+ FOR_EACH_BB (bb)
{
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;
@@ -797,7 +787,7 @@ branch_prob ()
{
/* We should not get abort here, as call to setjmp should not
be the very first instruction of function. */
- if (!i)
+ if (bb == ENTRY_BLOCK_PTR)
abort ();
make_edge (ENTRY_BLOCK_PTR, bb, EDGE_FAKE);
}
@@ -864,10 +854,8 @@ branch_prob ()
GCOV utility. */
if (flag_test_coverage)
{
- int i = 0;
- for (i = 0 ; i < n_basic_blocks; i++)
+ FOR_EACH_BB (bb)
{
- basic_block bb = BASIC_BLOCK (i);
rtx insn = bb->head;
static int ignore_next_note = 0;
@@ -976,9 +964,8 @@ branch_prob ()
__write_long (n_basic_blocks + 2, bbg_file, 4);
__write_long (num_edges - ignored_edges + 1, bbg_file, 4);
- for (i = 0; i < n_basic_blocks + 1; i++)
+ FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, EXIT_BLOCK_PTR, next_bb)
{
- basic_block bb = GCOV_INDEX_TO_BB (i);
edge e;
long count = 0;
@@ -1088,12 +1075,11 @@ find_spanning_tree (el)
{
int i;
int num_edges = NUM_EDGES (el);
+ basic_block bb;
/* We use aux field for standard union-find algorithm. */
- EXIT_BLOCK_PTR->aux = EXIT_BLOCK_PTR;
- ENTRY_BLOCK_PTR->aux = ENTRY_BLOCK_PTR;
- for (i = 0; i < n_basic_blocks; i++)
- BASIC_BLOCK (i)->aux = BASIC_BLOCK (i);
+ FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+ bb->aux = bb;
/* Add fake edge exit to entry we can't instrument. */
union_groups (EXIT_BLOCK_PTR, ENTRY_BLOCK_PTR);
@@ -1149,10 +1135,8 @@ find_spanning_tree (el)
}
}
- EXIT_BLOCK_PTR->aux = NULL;
- ENTRY_BLOCK_PTR->aux = NULL;
- for (i = 0; i < n_basic_blocks; i++)
- BASIC_BLOCK (i)->aux = NULL;
+ FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb)
+ bb->aux = NULL;
}
/* Perform file-level initialization for branch-prob processing. */