summaryrefslogtreecommitdiff
path: root/gcc/gcov-dump.c
diff options
context:
space:
mode:
authortejohnson <tejohnson@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-03 20:51:28 +0000
committertejohnson <tejohnson@138bc75d-0d04-0410-961f-82ee72b054a4>2013-04-03 20:51:28 +0000
commit8515a84d85b234ea831bb275a6c01fbd3cdd4118 (patch)
treeadc203a589f57f6641e15408a2579a630f743208 /gcc/gcov-dump.c
parent687a1ea1e7115e06810cc1e7b59d3831eabdb0dc (diff)
downloadgcc-8515a84d85b234ea831bb275a6c01fbd3cdd4118.tar.gz
This patch enables the gcov-dump tool to optionally compute and dump
the working set information from the counter histogram, via a new -w option. This is useful to help understand and tune how the compiler will use the counter histogram, since it first computes the working set and selects thresholds based on that. This required moving the bulk of the compute_working_sets functionality into gcov-io.c so that it was accessible by gcov-dump.c. 2013-04-03 Teresa Johnson <tejohnson@google.com> * gcov-io.c (compute_working_sets): Moved most of body of old compute_working_sets here from profile.c. * gcov-io.h (NUM_GCOV_WORKING_SETS): Moved here from profile.c. (gcov_working_set_t): Moved typedef here from basic-block.h (compute_working_set): Declare. * profile.c (NUM_GCOV_WORKING_SETS): Moved to gcov-io.h. (get_working_sets): Renamed from compute_working_set, replace most of body with call to new compute_working_sets. (get_exec_counts): Replace call to compute_working_sets to get_working_sets. * profile.h (get_working_sets): Renamed from compute_working_set. * lto-cgraph.c (input_symtab): Replace call to compute_working_sets to get_working_sets. * basic-block.h (gcov_working_set_t): Moved to gcov-io.h. * gcov-dump.c (dump_working_sets): New function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@197457 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/gcov-dump.c')
-rw-r--r--gcc/gcov-dump.c44
1 files changed, 43 insertions, 1 deletions
diff --git a/gcc/gcov-dump.c b/gcc/gcov-dump.c
index 3f3d4554cbf..7f8e23109f8 100644
--- a/gcc/gcov-dump.c
+++ b/gcc/gcov-dump.c
@@ -38,6 +38,8 @@ static void tag_arcs (const char *, unsigned, unsigned);
static void tag_lines (const char *, unsigned, unsigned);
static void tag_counters (const char *, unsigned, unsigned);
static void tag_summary (const char *, unsigned, unsigned);
+static void dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
+ const struct gcov_ctr_summary *summary);
extern int main (int, char **);
typedef struct tag_format
@@ -49,6 +51,7 @@ typedef struct tag_format
static int flag_dump_contents = 0;
static int flag_dump_positions = 0;
+static int flag_dump_working_sets = 0;
static const struct option options[] =
{
@@ -56,6 +59,7 @@ static const struct option options[] =
{ "version", no_argument, NULL, 'v' },
{ "long", no_argument, NULL, 'l' },
{ "positions", no_argument, NULL, 'o' },
+ { "working-sets", no_argument, NULL, 'w' },
{ 0, 0, 0, 0 }
};
@@ -93,7 +97,7 @@ main (int argc ATTRIBUTE_UNUSED, char **argv)
diagnostic_initialize (global_dc, 0);
- while ((opt = getopt_long (argc, argv, "hlpv", options, NULL)) != -1)
+ while ((opt = getopt_long (argc, argv, "hlpvw", options, NULL)) != -1)
{
switch (opt)
{
@@ -109,6 +113,9 @@ main (int argc ATTRIBUTE_UNUSED, char **argv)
case 'p':
flag_dump_positions = 1;
break;
+ case 'w':
+ flag_dump_working_sets = 1;
+ break;
default:
fprintf (stderr, "unknown flag `%c'\n", opt);
}
@@ -128,6 +135,7 @@ print_usage (void)
printf (" -v, --version Print version number\n");
printf (" -l, --long Dump record contents too\n");
printf (" -p, --positions Dump record positions\n");
+ printf (" -w, --working-sets Dump working set computed from summary\n");
}
static void
@@ -484,5 +492,39 @@ tag_summary (const char *filename ATTRIBUTE_UNUSED,
(HOST_WIDEST_INT)histo_bucket->min_value,
(HOST_WIDEST_INT)histo_bucket->cum_value);
}
+ if (flag_dump_working_sets)
+ dump_working_sets (filename, &summary.ctrs[ix]);
+ }
+}
+
+static void
+dump_working_sets (const char *filename ATTRIBUTE_UNUSED,
+ const struct gcov_ctr_summary *summary)
+{
+ gcov_working_set_t gcov_working_sets[NUM_GCOV_WORKING_SETS];
+ unsigned ws_ix, pctinc, pct;
+ gcov_working_set_t *ws_info;
+
+ compute_working_sets (summary, gcov_working_sets);
+
+ printf ("\n");
+ print_prefix (filename, 0, 0);
+ printf ("\t\tcounter working sets:");
+ /* Multiply the percentage by 100 to avoid float. */
+ pctinc = 100 * 100 / NUM_GCOV_WORKING_SETS;
+ for (ws_ix = 0, pct = pctinc; ws_ix < NUM_GCOV_WORKING_SETS;
+ ws_ix++, pct += pctinc)
+ {
+ if (ws_ix == NUM_GCOV_WORKING_SETS - 1)
+ pct = 9990;
+ ws_info = &gcov_working_sets[ws_ix];
+ /* Print out the percentage using int arithmatic to avoid float. */
+ printf ("\n");
+ print_prefix (filename, 0, 0);
+ printf ("\t\t%u.%02u%%: num counts=%u, min counter="
+ HOST_WIDEST_INT_PRINT_DEC,
+ pct / 100, pct - (pct / 100 * 100),
+ ws_info->num_counters,
+ (HOST_WIDEST_INT)ws_info->min_counter);
}
}