* [google] Fix bugs in sampled profile collection
@ 2011-10-01 1:55 Easwaran Raman
2011-10-01 4:12 ` Xinliang David Li
0 siblings, 1 reply; 2+ messages in thread
From: Easwaran Raman @ 2011-10-01 1:55 UTC (permalink / raw)
To: gcc-patches; +Cc: Xinliang David Li
This fixes two issues with sampled profile collection. It delays
cleanup of instrumentation_to_be_sampled after all callgraph nodes
have been instrumented and prevents gcov_sample_counter_decl and
gcov_sampling_rate_decl from being garbage collected.
Ok for google/gcc-4_6 and google/main branches?
-Easwaran
2011-09-30 Easwaran Raman <eraman@google.com>
* tree-profile.c (gcov_sample_counter_decl): Add GTY marker.
(gcov_sampling_rate_decl): Likewise.
(add_sampling_to_edge_counters): Do not free
instrumentation_to_be_sampled.
(cleanup_instrumentation_sampling): New function.
(tree_profiling): Call cleanup_instrumentation_sampling at the end.
testsuite/ChangeLog.google-4_6:
2011-09-30 Easwaran Raman <eraman@google.com>
* gcc.dg/sample-profile-generate-1.c: New test.
Index: gcc/testsuite/gcc.dg/sample-profile-generate-1.c
===================================================================
--- gcc/testsuite/gcc.dg/sample-profile-generate-1.c (revision 0)
+++ gcc/testsuite/gcc.dg/sample-profile-generate-1.c (revision 0)
@@ -0,0 +1,26 @@
+/* { dg-do compile} */
+/* { dg-options "-O2 -fprofile-generate -fprofile-generate-sampling" } */
+
+void foobar(int);
+
+void
+foo (void)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ foobar(i);
+ }
+}
+
+void
+bar (void)
+{
+ int i;
+ for (i = 0; i < 100; i++)
+ {
+ foobar(i);
+ }
+}
+
+/* { dg-final { cleanup-coverage-files } } */
Index: tree-profile.c
===================================================================
--- tree-profile.c (revision 178897)
+++ tree-profile.c (working copy)
@@ -163,10 +163,10 @@ init_ic_make_global_vars (void)
static struct pointer_set_t *instrumentation_to_be_sampled = NULL;
/* extern __thread gcov_unsigned_t __gcov_sample_counter */
-static tree gcov_sample_counter_decl = NULL_TREE;
+static GTY(()) tree gcov_sample_counter_decl = NULL_TREE;
/* extern gcov_unsigned_t __gcov_sampling_rate */
-static tree gcov_sampling_rate_decl = NULL_TREE;
+static GTY(()) tree gcov_sampling_rate_decl = NULL_TREE;
/* forward declaration. */
void gimple_init_instrumentation_sampling (void);
@@ -281,9 +281,13 @@ add_sampling_to_edge_counters (void)
break;
}
}
+}
+static void
+cleanup_instrumentation_sampling (void)
+{
/* Free the bitmap. */
- if (instrumentation_to_be_sampled)
+ if (flag_profile_generate_sampling && instrumentation_to_be_sampled)
{
pointer_set_destroy (instrumentation_to_be_sampled);
instrumentation_to_be_sampled = NULL;
@@ -1452,6 +1456,7 @@ tree_profiling (void)
}
del_node_map();
+ cleanup_instrumentation_sampling();
return 0;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [google] Fix bugs in sampled profile collection
2011-10-01 1:55 [google] Fix bugs in sampled profile collection Easwaran Raman
@ 2011-10-01 4:12 ` Xinliang David Li
0 siblings, 0 replies; 2+ messages in thread
From: Xinliang David Li @ 2011-10-01 4:12 UTC (permalink / raw)
To: Easwaran Raman; +Cc: gcc-patches
ok.
David
On Fri, Sep 30, 2011 at 6:54 PM, Easwaran Raman <eraman@google.com> wrote:
> This fixes two issues with sampled profile collection. It delays
> cleanup of instrumentation_to_be_sampled after all callgraph nodes
> have been instrumented and prevents gcov_sample_counter_decl and
> gcov_sampling_rate_decl from being garbage collected.
>
> Ok for google/gcc-4_6 and google/main branches?
>
> -Easwaran
>
> 2011-09-30 Easwaran Raman <eraman@google.com>
>
> * tree-profile.c (gcov_sample_counter_decl): Add GTY marker.
> (gcov_sampling_rate_decl): Likewise.
> (add_sampling_to_edge_counters): Do not free
> instrumentation_to_be_sampled.
> (cleanup_instrumentation_sampling): New function.
> (tree_profiling): Call cleanup_instrumentation_sampling at the end.
>
> testsuite/ChangeLog.google-4_6:
>
> 2011-09-30 Easwaran Raman <eraman@google.com>
>
> * gcc.dg/sample-profile-generate-1.c: New test.
>
> Index: gcc/testsuite/gcc.dg/sample-profile-generate-1.c
> ===================================================================
> --- gcc/testsuite/gcc.dg/sample-profile-generate-1.c (revision 0)
> +++ gcc/testsuite/gcc.dg/sample-profile-generate-1.c (revision 0)
> @@ -0,0 +1,26 @@
> +/* { dg-do compile} */
> +/* { dg-options "-O2 -fprofile-generate -fprofile-generate-sampling" } */
> +
> +void foobar(int);
> +
> +void
> +foo (void)
> +{
> + int i;
> + for (i = 0; i < 100; i++)
> + {
> + foobar(i);
> + }
> +}
> +
> +void
> +bar (void)
> +{
> + int i;
> + for (i = 0; i < 100; i++)
> + {
> + foobar(i);
> + }
> +}
> +
> +/* { dg-final { cleanup-coverage-files } } */
>
> Index: tree-profile.c
> ===================================================================
> --- tree-profile.c (revision 178897)
> +++ tree-profile.c (working copy)
> @@ -163,10 +163,10 @@ init_ic_make_global_vars (void)
> static struct pointer_set_t *instrumentation_to_be_sampled = NULL;
>
> /* extern __thread gcov_unsigned_t __gcov_sample_counter */
> -static tree gcov_sample_counter_decl = NULL_TREE;
> +static GTY(()) tree gcov_sample_counter_decl = NULL_TREE;
>
> /* extern gcov_unsigned_t __gcov_sampling_rate */
> -static tree gcov_sampling_rate_decl = NULL_TREE;
> +static GTY(()) tree gcov_sampling_rate_decl = NULL_TREE;
>
> /* forward declaration. */
> void gimple_init_instrumentation_sampling (void);
> @@ -281,9 +281,13 @@ add_sampling_to_edge_counters (void)
> break;
> }
> }
> +}
>
> +static void
> +cleanup_instrumentation_sampling (void)
> +{
> /* Free the bitmap. */
> - if (instrumentation_to_be_sampled)
> + if (flag_profile_generate_sampling && instrumentation_to_be_sampled)
> {
> pointer_set_destroy (instrumentation_to_be_sampled);
> instrumentation_to_be_sampled = NULL;
> @@ -1452,6 +1456,7 @@ tree_profiling (void)
> }
>
> del_node_map();
> + cleanup_instrumentation_sampling();
> return 0;
> }
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-10-01 4:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-01 1:55 [google] Fix bugs in sampled profile collection Easwaran Raman
2011-10-01 4:12 ` Xinliang David Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).