From: "Martin Liška" <mliska@suse.cz>
To: Jan Hubicka <hubicka@ucw.cz>, Xiong Hu Luo <luoxhu@linux.ibm.com>
Cc: gcc-patches@gcc.gnu.org, segher@kernel.crashing.org,
wschmidt@linux.ibm.com, luoxhu@cn.ibm.com
Subject: Re: [PATCH] [RFC, PGO+LTO] Missed function specialization + partial devirtualization
Date: Thu, 20 Jun 2019 14:45:00 -0000 [thread overview]
Message-ID: <254432df-7f6d-d715-c916-b35bd0c94b0c@suse.cz> (raw)
In-Reply-To: <20190620134731.fhjf7ezskq55yz6o@kam.mff.cuni.cz>
[-- Attachment #1: Type: text/plain, Size: 188 bytes --]
Hi.
So the first part is about support of N tracked values to be supported.
Patch can bootstrap on x86_64-linux-gnu and survives regression tests.
Ready to be installed?
Thanks,
Martin
[-- Attachment #2: 0001-Support-N-values-in-libgcov-for-single-value-counter.patch --]
[-- Type: text/x-patch, Size: 5382 bytes --]
From f3e361fb6d799acf538bc76a91bfcc8e265b7cbe Mon Sep 17 00:00:00 2001
From: Martin Liska <mliska@suse.cz>
Date: Wed, 19 Jun 2019 14:15:14 +0200
Subject: [PATCH 1/2] Support N values in libgcov for single value counter
type.
gcc/testsuite/ChangeLog:
2019-06-20 Martin Liska <mliska@suse.cz>
* gcc.dg/tree-prof/val-prof-2.c: Update scanned pattern
as we do now better.
libgcc/ChangeLog:
2019-06-20 Martin Liska <mliska@suse.cz>
* libgcov-merge.c (merge_single_value_set): Support N values.
* libgcov-profiler.c (__gcov_one_value_profiler_body): Likewise.
---
gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c | 5 +--
libgcc/libgcov-merge.c | 48 +++++++++++----------
libgcc/libgcov-profiler.c | 42 ++++++++++++++----
3 files changed, 60 insertions(+), 35 deletions(-)
diff --git a/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c b/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c
index 8cb3c64fd17..b3bbadfeb40 100644
--- a/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c
+++ b/gcc/testsuite/gcc.dg/tree-prof/val-prof-2.c
@@ -25,8 +25,5 @@ main ()
return 0;
}
/* autofdo does not do value profiling so far */
-/* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: mod power of 2" "profile" } } */
-/* This is part of code checking that n is power of 2, so we are sure that the transformation
- didn't get optimized out. */
-/* { dg-final-use-not-autofdo { scan-tree-dump "n_\[0-9\]* \\+ (4294967295|0x0*ffffffff)" "optimized"} } */
+/* { dg-final-use-not-autofdo { scan-ipa-dump "Transformation done: div/mod by constant 256" "profile" } } */
/* { dg-final-use { scan-tree-dump-not "Invalid sum" "optimized"} } */
diff --git a/libgcc/libgcov-merge.c b/libgcc/libgcov-merge.c
index f778cc4b6b7..84367005663 100644
--- a/libgcc/libgcov-merge.c
+++ b/libgcc/libgcov-merge.c
@@ -89,49 +89,53 @@ __gcov_merge_time_profile (gcov_type *counters, unsigned n_counters)
static void
merge_single_value_set (gcov_type *counters)
{
- unsigned j;
- gcov_type value, counter;
-
/* First value is number of total executions of the profiler. */
gcov_type all = gcov_get_counter_ignore_scaling (-1);
counters[0] += all;
++counters;
+ /* Read all part values. */
+ gcov_type read_counters[2 * GCOV_DISK_SINGLE_VALUES];
+
for (unsigned i = 0; i < GCOV_DISK_SINGLE_VALUES; i++)
{
- value = gcov_get_counter_target ();
- counter = gcov_get_counter_ignore_scaling (-1);
+ read_counters[2 * i] = gcov_get_counter_target ();
+ read_counters[2 * i + 1] = gcov_get_counter_ignore_scaling (-1);
+ }
- if (counter == -1)
- {
- counters[1] = -1;
- /* We can't return as we need to read all counters. */
- continue;
- }
- else if (counter == 0 || counters[1] == -1)
- {
- /* We can't return as we need to read all counters. */
- continue;
- }
+ if (read_counters[1] == -1)
+ {
+ counters[1] = -1;
+ return;
+ }
+
+ for (unsigned i = 0; i < GCOV_DISK_SINGLE_VALUES; i++)
+ {
+ if (read_counters[2 * i + 1] == 0)
+ return;
+ unsigned j;
for (j = 0; j < GCOV_DISK_SINGLE_VALUES; j++)
{
- if (counters[2 * j] == value)
+ if (counters[2 * j] == read_counters[2 * i])
{
- counters[2 * j + 1] += counter;
+ counters[2 * j + 1] += read_counters[2 * i + 1];
break;
}
else if (counters[2 * j + 1] == 0)
{
- counters[2 * j] = value;
- counters[2 * j + 1] = counter;
+ counters[2 * j] += read_counters[2 * i];
+ counters[2 * j + 1] += read_counters[2 * i + 1];
break;
}
}
- /* We haven't found a free slot for the value, mark overflow. */
+ /* We haven't found a slot, bail out. */
if (j == GCOV_DISK_SINGLE_VALUES)
- counters[1] = -1;
+ {
+ counters[1] = -1;
+ return;
+ }
}
}
diff --git a/libgcc/libgcov-profiler.c b/libgcc/libgcov-profiler.c
index 9ba65b90df3..04d6f9c0e40 100644
--- a/libgcc/libgcov-profiler.c
+++ b/libgcc/libgcov-profiler.c
@@ -118,20 +118,44 @@ static inline void
__gcov_one_value_profiler_body (gcov_type *counters, gcov_type value,
int use_atomic)
{
- if (value == counters[1])
- counters[2]++;
- else if (counters[2] == 0)
+ if (use_atomic)
+ __atomic_fetch_add (&counters[0], 1, __ATOMIC_RELAXED);
+ else
+ counters[0]++;
+
+ ++counters;
+
+ /* We have GCOV_DISK_SINGLE_VALUES as we can keep multiple values
+ next to each other. */
+ unsigned sindex = 0;
+
+ for (unsigned i = 0; i < GCOV_DISK_SINGLE_VALUES; i++)
{
- counters[2] = 1;
- counters[1] = value;
+ if (value == counters[2 * i])
+ {
+ if (use_atomic)
+ __atomic_fetch_add (&counters[2 * i + 1], 1, __ATOMIC_RELAXED);
+ else
+ counters[2 * i + 1]++;
+ return;
+ }
+ else if (counters[2 * i + 1] == 0)
+ {
+ /* We found an empty slot. */
+ counters[2 * i] = value;
+ counters[2 * i + 1] = 1;
+ return;
+ }
+
+ if (counters[2 * i + 1] < counters[2 * sindex + 1])
+ sindex = i;
}
- else
- counters[2]--;
+ /* We haven't found an empty slot, then decrement the smallest. */
if (use_atomic)
- __atomic_fetch_add (&counters[0], 1, __ATOMIC_RELAXED);
+ __atomic_fetch_sub (&counters[2 * sindex + 1], 1, __ATOMIC_RELAXED);
else
- counters[0]++;
+ counters[2 * sindex + 1]--;
}
#ifdef L_gcov_one_value_profiler_v2
--
2.21.0
next prev parent reply other threads:[~2019-06-20 14:45 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-18 1:46 Xiong Hu Luo
2019-06-18 5:51 ` Martin Liška
2019-06-18 9:03 ` luoxhu
2019-06-18 9:34 ` Martin Liška
2019-06-18 10:07 ` Segher Boessenkool
2019-06-18 10:20 ` Martin Liška
2019-06-19 5:38 ` luoxhu
2019-06-19 6:57 ` Martin Liška
2019-06-18 10:21 ` Martin Liška
2019-06-19 8:50 ` luoxhu
2019-06-19 8:56 ` Martin Liška
2019-06-19 12:18 ` Martin Liška
2019-06-20 1:59 ` luoxhu
2019-06-20 6:15 ` luoxhu
2019-06-20 12:57 ` Martin Liška
2019-06-20 13:47 ` Jan Hubicka
2019-06-20 14:45 ` Martin Liška [this message]
2019-07-01 11:20 ` Martin Liška
2019-07-03 9:08 ` Jan Hubicka
2019-06-20 14:46 ` [PATCH 2/2] Rename SINGE_VALUE to TOPN_VALUES counters Martin Liška
2019-07-01 11:21 ` Martin Liška
2019-07-03 9:09 ` Jan Hubicka
2019-07-03 12:41 ` Martin Liška
2019-06-24 2:34 ` [PATCH] [RFC, PGO+LTO] Missed function specialization + partial devirtualization luoxhu
2019-06-24 9:20 ` luoxhu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=254432df-7f6d-d715-c916-b35bd0c94b0c@suse.cz \
--to=mliska@suse.cz \
--cc=gcc-patches@gcc.gnu.org \
--cc=hubicka@ucw.cz \
--cc=luoxhu@cn.ibm.com \
--cc=luoxhu@linux.ibm.com \
--cc=segher@kernel.crashing.org \
--cc=wschmidt@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).