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.
This commit is contained in:
parent
409767d774
commit
7553bd35c8
|
@ -571,8 +571,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.
|
||||
|
|
13
gcc/system.h
13
gcc/system.h
|
@ -1305,4 +1305,17 @@ startswith (const char *str, const char *prefix)
|
|||
return strncmp (str, prefix, strlen (prefix)) == 0;
|
||||
}
|
||||
|
||||
/* 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 */
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
/* PR gcov-profile/100520 */
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-fcompare-debug -fprofile-generate" } */
|
||||
|
||||
static int f() {}
|
Loading…
Reference in New Issue