public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-9221] gcov-profile: Fix -fcompare-debug with -fprofile-generate [PR100520] Date: Mon, 8 Nov 2021 12:26:44 +0000 (GMT) [thread overview] Message-ID: <20211108122644.DF99E3858406@sourceware.org> (raw) https://gcc.gnu.org/g:580d66f5a0bdcd88dcdab2d4ace3bbbaae121af3 commit r11-9221-g580d66f5a0bdcd88dcdab2d4ace3bbbaae121af3 Author: Martin Liska <mliska@suse.cz> Date: Fri Nov 5 16:50:06 2021 +0100 gcov-profile: Fix -fcompare-debug with -fprofile-generate [PR100520] PR gcov-profile/100520 gcc/ChangeLog: * coverage.c (coverage_compute_profile_id): Strip .gk when compare debug is used. * system.h (endswith): New function. gcc/testsuite/ChangeLog: * gcc.dg/pr100520.c: New test. (cherry picked from commit 7553bd35c876efaf8ab0b6661a6102822b99e6e3) Diff: --- gcc/coverage.c | 7 +++++-- gcc/system.h | 13 +++++++++++++ gcc/testsuite/gcc.dg/pr100520.c | 5 +++++ 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/gcc/coverage.c b/gcc/coverage.c index 9b98e0173ab..17d1beeca3d 100644 --- a/gcc/coverage.c +++ b/gcc/coverage.c @@ -576,8 +576,11 @@ coverage_compute_profile_id (struct cgraph_node *n) if (!use_name_only && first_global_object_name) chksum = coverage_checksum_string (chksum, first_global_object_name); - chksum = coverage_checksum_string - (chksum, aux_base_name); + char *base_name = xstrdup (aux_base_name); + if (endswith (base_name, ".gk")) + base_name[strlen (base_name) - 3] = '\0'; + chksum = coverage_checksum_string (chksum, base_name); + free (base_name); } /* Non-negative integers are hopefully small enough to fit in all targets. diff --git a/gcc/system.h b/gcc/system.h index a3f5948aaee..b13e9429577 100644 --- a/gcc/system.h +++ b/gcc/system.h @@ -1291,4 +1291,17 @@ void gcc_stablesort (void *, size_t, size_t, #define NULL nullptr #endif +/* Return true if STR string ends with SUFFIX. */ + +static inline bool +endswith (const char *str, const char *suffix) +{ + size_t str_len = strlen (str); + size_t suffix_len = strlen (suffix); + if (str_len < suffix_len) + return false; + + return memcmp (str + str_len - suffix_len, suffix, suffix_len) == 0; +} + #endif /* ! GCC_SYSTEM_H */ diff --git a/gcc/testsuite/gcc.dg/pr100520.c b/gcc/testsuite/gcc.dg/pr100520.c new file mode 100644 index 00000000000..60f79c2b888 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr100520.c @@ -0,0 +1,5 @@ +/* PR gcov-profile/100520 */ +/* { dg-do compile } */ +/* { dg-options "-fcompare-debug -fprofile-generate" } */ + +static int f() {}
reply other threads:[~2021-11-08 12:26 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20211108122644.DF99E3858406@sourceware.org \ --to=marxin@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /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: linkBe 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).