Mercurial > hg > CbC > CbC_gcc
comparison gcc/profile.c @ 55:77e2b8dfacca gcc-4.4.5
update it from 4.4.3 to 4.5.0
author | ryoma <e075725@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 12 Feb 2010 23:39:51 +0900 |
parents | a06113de4d67 |
children | f6334be47118 |
comparison
equal
deleted
inserted
replaced
52:c156f1bd5cd9 | 55:77e2b8dfacca |
---|---|
1 /* Calculate branch probabilities, and basic block execution counts. | 1 /* Calculate branch probabilities, and basic block execution counts. |
2 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999, | 2 Copyright (C) 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 1999, |
3 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008 | 3 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 |
4 Free Software Foundation, Inc. | 4 Free Software Foundation, Inc. |
5 Contributed by James E. Wilson, UC Berkeley/Cygnus Support; | 5 Contributed by James E. Wilson, UC Berkeley/Cygnus Support; |
6 based on some ideas from Dain Samples of UC Berkeley. | 6 based on some ideas from Dain Samples of UC Berkeley. |
7 Further mangling by Bob Manson, Cygnus Support. | 7 Further mangling by Bob Manson, Cygnus Support. |
8 | 8 |
98 static int total_num_edges_instrumented; | 98 static int total_num_edges_instrumented; |
99 static int total_num_blocks_created; | 99 static int total_num_blocks_created; |
100 static int total_num_passes; | 100 static int total_num_passes; |
101 static int total_num_times_called; | 101 static int total_num_times_called; |
102 static int total_hist_br_prob[20]; | 102 static int total_hist_br_prob[20]; |
103 static int total_num_never_executed; | |
104 static int total_num_branches; | 103 static int total_num_branches; |
105 | 104 |
106 /* Forward declarations. */ | 105 /* Forward declarations. */ |
107 static void find_spanning_tree (struct edge_list *); | 106 static void find_spanning_tree (struct edge_list *); |
108 static unsigned instrument_edges (struct edge_list *); | 107 static unsigned instrument_edges (struct edge_list *); |
342 } | 341 } |
343 if (bb->count != sum_edge_counts (bb->preds)) | 342 if (bb->count != sum_edge_counts (bb->preds)) |
344 { | 343 { |
345 if (dump_file) | 344 if (dump_file) |
346 { | 345 { |
347 fprintf (dump_file, "BB %i count does not match sum of incomming edges " | 346 fprintf (dump_file, "BB %i count does not match sum of incoming edges " |
348 HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC, | 347 HOST_WIDEST_INT_PRINT_DEC" should be " HOST_WIDEST_INT_PRINT_DEC, |
349 bb->index, | 348 bb->index, |
350 bb->count, | 349 bb->count, |
351 sum_edge_counts (bb->preds)); | 350 sum_edge_counts (bb->preds)); |
352 dump_bb (bb, dump_file, 0); | 351 dump_bb (bb, dump_file, 0); |
445 int i; | 444 int i; |
446 int num_edges = 0; | 445 int num_edges = 0; |
447 int changes; | 446 int changes; |
448 int passes; | 447 int passes; |
449 int hist_br_prob[20]; | 448 int hist_br_prob[20]; |
450 int num_never_executed; | |
451 int num_branches; | 449 int num_branches; |
452 gcov_type *exec_counts = get_exec_counts (); | 450 gcov_type *exec_counts = get_exec_counts (); |
453 int inconsistent = 0; | 451 int inconsistent = 0; |
454 | 452 |
455 /* Very simple sanity checks so we catch bugs in our profiling code. */ | 453 /* Very simple sanity checks so we catch bugs in our profiling code. */ |
645 /* For every edge, calculate its branch probability and add a reg_note | 643 /* For every edge, calculate its branch probability and add a reg_note |
646 to the branch insn to indicate this. */ | 644 to the branch insn to indicate this. */ |
647 | 645 |
648 for (i = 0; i < 20; i++) | 646 for (i = 0; i < 20; i++) |
649 hist_br_prob[i] = 0; | 647 hist_br_prob[i] = 0; |
650 num_never_executed = 0; | |
651 num_branches = 0; | 648 num_branches = 0; |
652 | 649 |
653 FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) | 650 FOR_BB_BETWEEN (bb, ENTRY_BLOCK_PTR, NULL, next_bb) |
654 { | 651 { |
655 edge e; | 652 edge e; |
739 e->probability = REG_BR_PROB_BASE / total; | 736 e->probability = REG_BR_PROB_BASE / total; |
740 } | 737 } |
741 if (bb->index >= NUM_FIXED_BLOCKS | 738 if (bb->index >= NUM_FIXED_BLOCKS |
742 && block_ends_with_condjump_p (bb) | 739 && block_ends_with_condjump_p (bb) |
743 && EDGE_COUNT (bb->succs) >= 2) | 740 && EDGE_COUNT (bb->succs) >= 2) |
744 num_branches++, num_never_executed; | 741 num_branches++; |
745 } | 742 } |
746 } | 743 } |
747 counts_to_freqs (); | 744 counts_to_freqs (); |
748 profile_status = PROFILE_READ; | 745 profile_status = PROFILE_READ; |
749 | 746 |
750 if (dump_file) | 747 if (dump_file) |
751 { | 748 { |
752 fprintf (dump_file, "%d branches\n", num_branches); | 749 fprintf (dump_file, "%d branches\n", num_branches); |
753 fprintf (dump_file, "%d branches never executed\n", | |
754 num_never_executed); | |
755 if (num_branches) | 750 if (num_branches) |
756 for (i = 0; i < 10; i++) | 751 for (i = 0; i < 10; i++) |
757 fprintf (dump_file, "%d%% branches in range %d-%d%%\n", | 752 fprintf (dump_file, "%d%% branches in range %d-%d%%\n", |
758 (hist_br_prob[i] + hist_br_prob[19-i]) * 100 / num_branches, | 753 (hist_br_prob[i] + hist_br_prob[19-i]) * 100 / num_branches, |
759 5 * i, 5 * i + 5); | 754 5 * i, 5 * i + 5); |
760 | 755 |
761 total_num_branches += num_branches; | 756 total_num_branches += num_branches; |
762 total_num_never_executed += num_never_executed; | |
763 for (i = 0; i < 20; i++) | 757 for (i = 0; i < 20; i++) |
764 total_hist_br_prob[i] += hist_br_prob[i]; | 758 total_hist_br_prob[i] += hist_br_prob[i]; |
765 | 759 |
766 fputc ('\n', dump_file); | 760 fputc ('\n', dump_file); |
767 fputc ('\n', dump_file); | 761 fputc ('\n', dump_file); |
779 unsigned i, j, t, any; | 773 unsigned i, j, t, any; |
780 unsigned n_histogram_counters[GCOV_N_VALUE_COUNTERS]; | 774 unsigned n_histogram_counters[GCOV_N_VALUE_COUNTERS]; |
781 gcov_type *histogram_counts[GCOV_N_VALUE_COUNTERS]; | 775 gcov_type *histogram_counts[GCOV_N_VALUE_COUNTERS]; |
782 gcov_type *act_count[GCOV_N_VALUE_COUNTERS]; | 776 gcov_type *act_count[GCOV_N_VALUE_COUNTERS]; |
783 gcov_type *aact_count; | 777 gcov_type *aact_count; |
784 | 778 |
785 for (t = 0; t < GCOV_N_VALUE_COUNTERS; t++) | 779 for (t = 0; t < GCOV_N_VALUE_COUNTERS; t++) |
786 n_histogram_counters[t] = 0; | 780 n_histogram_counters[t] = 0; |
787 | 781 |
788 for (i = 0; i < VEC_length (histogram_value, values); i++) | 782 for (i = 0; i < VEC_length (histogram_value, values); i++) |
789 { | 783 { |
947 if (gimple_has_location (last)) | 941 if (gimple_has_location (last)) |
948 break; | 942 break; |
949 } | 943 } |
950 | 944 |
951 /* Edge with goto locus might get wrong coverage info unless | 945 /* Edge with goto locus might get wrong coverage info unless |
952 it is the only edge out of BB. | 946 it is the only edge out of BB. |
953 Don't do that when the locuses match, so | 947 Don't do that when the locuses match, so |
954 if (blah) goto something; | 948 if (blah) goto something; |
955 is not computed twice. */ | 949 is not computed twice. */ |
956 if (last | 950 if (last |
957 && gimple_has_location (last) | 951 && gimple_has_location (last) |
958 && e->goto_locus != UNKNOWN_LOCATION | 952 && e->goto_locus != UNKNOWN_LOCATION |
1131 | 1125 |
1132 offset = 0; | 1126 offset = 0; |
1133 | 1127 |
1134 if (bb == ENTRY_BLOCK_PTR->next_bb) | 1128 if (bb == ENTRY_BLOCK_PTR->next_bb) |
1135 { | 1129 { |
1136 expanded_location curr_location = | 1130 expanded_location curr_location = |
1137 expand_location (DECL_SOURCE_LOCATION (current_function_decl)); | 1131 expand_location (DECL_SOURCE_LOCATION (current_function_decl)); |
1138 output_location (curr_location.file, curr_location.line, | 1132 output_location (curr_location.file, curr_location.line, |
1139 &offset, bb); | 1133 &offset, bb); |
1140 } | 1134 } |
1141 | 1135 |
1331 total_num_edges_instrumented = 0; | 1325 total_num_edges_instrumented = 0; |
1332 total_num_blocks_created = 0; | 1326 total_num_blocks_created = 0; |
1333 total_num_passes = 0; | 1327 total_num_passes = 0; |
1334 total_num_times_called = 0; | 1328 total_num_times_called = 0; |
1335 total_num_branches = 0; | 1329 total_num_branches = 0; |
1336 total_num_never_executed = 0; | |
1337 for (i = 0; i < 20; i++) | 1330 for (i = 0; i < 20; i++) |
1338 total_hist_br_prob[i] = 0; | 1331 total_hist_br_prob[i] = 0; |
1339 } | 1332 } |
1340 | 1333 |
1341 /* Performs file-level cleanup after branch-prob processing | 1334 /* Performs file-level cleanup after branch-prob processing |
1362 fprintf (dump_file, "Average number of graph solution passes: %d\n", | 1355 fprintf (dump_file, "Average number of graph solution passes: %d\n", |
1363 (total_num_passes + (total_num_times_called >> 1)) | 1356 (total_num_passes + (total_num_times_called >> 1)) |
1364 / total_num_times_called); | 1357 / total_num_times_called); |
1365 fprintf (dump_file, "Total number of branches: %d\n", | 1358 fprintf (dump_file, "Total number of branches: %d\n", |
1366 total_num_branches); | 1359 total_num_branches); |
1367 fprintf (dump_file, "Total number of branches never executed: %d\n", | |
1368 total_num_never_executed); | |
1369 if (total_num_branches) | 1360 if (total_num_branches) |
1370 { | 1361 { |
1371 int i; | 1362 int i; |
1372 | 1363 |
1373 for (i = 0; i < 10; i++) | 1364 for (i = 0; i < 10; i++) |