commit:     bb00f570a7d3f1d0e4233f8d353fb9c56f3a55cc
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 10 21:37:36 2020 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Thu Sep 10 21:37:36 2020 +0000
URL:        https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=bb00f570

10.2.0: fix TOPN counters when logged from shared library

The change does not yet fix underlying problem of recursive inliner.

Bug: https://gcc.gnu.org/PR96913
Bug: https://gcc.gnu.org/PR96394
Bug: https://bugs.gentoo.org/734006
Signed-off-by: Sergei Trofimovich <slyfox <AT> gentoo.org>

 10.2.0/gentoo/38_all_gcov-TOPN-PR96913.patch | 42 ++++++++++++++++++++++++++++
 10.2.0/gentoo/README.history                 |  1 +
 2 files changed, 43 insertions(+)

diff --git a/10.2.0/gentoo/38_all_gcov-TOPN-PR96913.patch 
b/10.2.0/gentoo/38_all_gcov-TOPN-PR96913.patch
new file mode 100644
index 0000000..5c301e4
--- /dev/null
+++ b/10.2.0/gentoo/38_all_gcov-TOPN-PR96913.patch
@@ -0,0 +1,42 @@
+https://gcc.gnu.org/PR96913
+https://gcc.gnu.org/PR96394
+https://bugs.gentoo.org/734006
+
+From ae887148e112e018bec0bab5bc15e53f2225037a Mon Sep 17 00:00:00 2001
+From: Sergei Trofimovich <siarh...@google.com>
+Date: Sun, 6 Sep 2020 12:13:54 +0100
+Subject: [PATCH] gcov: fix TOPN streaming from shared libraries
+
+Before the change gcc did not stream correctly TOPN counters
+if counters belonged to a non-local shared object.
+
+As a result zero-section optimization generated TOPN sections
+in a form not recognizable by '__gcov_merge_topn'.
+
+The problem happens because in a case of multiple shared objects
+'__gcov_merge_topn' function is present in address space multiple
+times (once per each object).
+
+The fix is to never rely on function address and predicate on TOPN
+counter types.
+
+libgcc/ChangeLog:
+
+       PR gcov-profile/96913
+       * libgcov-driver.c (write_one_data): Avoid function pointer
+       comparison in TOP streaming decision.
+---
+ libgcc/libgcov-driver.c | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+--- a/libgcc/libgcov-driver.c
++++ b/libgcc/libgcov-driver.c
+@@ -242,7 +242,7 @@ prune_counters (struct gcov_info *gi)
+         if (gi->merge[j] == NULL)
+           continue;
+ 
+-        if (gi->merge[j] == __gcov_merge_topn)
++        if (j == GCOV_COUNTER_V_TOPN || j == GCOV_COUNTER_V_INDIR)
+           {
+             gcc_assert (!(ci->num % GCOV_TOPN_VALUES_COUNTERS));
+             for (unsigned k = 0; k < (ci->num / GCOV_TOPN_VALUES_COUNTERS);

diff --git a/10.2.0/gentoo/README.history b/10.2.0/gentoo/README.history
index 3fbcbfd..6d00c5a 100644
--- a/10.2.0/gentoo/README.history
+++ b/10.2.0/gentoo/README.history
@@ -1,6 +1,7 @@
 3              TODO
        U 28_all_EXTRA_OPTIONS-fstack-clash-protection.patch
        + 37_all_c-vector-init-PR96377.patch
+       + 38_all_gcov-TOPN-PR96913.patch
 
 2              23 Aug 2020
        + 33_all_lto-O0-mix-ICE-ipa-PR96291.patch

Reply via email to