aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Hubicka <hubicka@ucw.cz>2025-07-07 17:18:23 +0200
committerJan Hubicka <hubicka@ucw.cz>2025-07-09 12:20:56 +0200
commit4de3524f9e88b7b22bdb481163b05a624f090cf9 (patch)
treee8f7502e73884ab040ffc547c710efb199588555
parent7a878ba615c2c51ea9cf89142033c5e1ad71795e (diff)
downloadgcc-4de3524f9e88b7b22bdb481163b05a624f090cf9.zip
gcc-4de3524f9e88b7b22bdb481163b05a624f090cf9.tar.gz
gcc-4de3524f9e88b7b22bdb481163b05a624f090cf9.tar.bz2
Fix auto-profile.cc:get_original_name
There are two bugs in get_original_name. FIrst the for loop walking list of known suffixes uses sizeos (suffixes). It evnetually walks to an empty suffix. Second problem is that strcmp may accept suffixes that are longer. I.e. mix up .isra with .israabc. This is probably not a big deal but the first bug makes get_original_name to effectively strip all suffixes, even important one on my setup. gcc/ChangeLog: * auto-profile.cc (get_original_name): Fix loop walking the suffixes.
-rw-r--r--gcc/auto-profile.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc
index a970eb8..1700bf8 100644
--- a/gcc/auto-profile.cc
+++ b/gcc/auto-profile.cc
@@ -622,9 +622,11 @@ get_original_name (const char *name, bool alloc = true)
}
/* Suffixes of clones that compiler generates after auto-profile. */
const char *suffixes[] = {"isra", "constprop", "lto_priv", "part", "cold"};
- for (unsigned i = 0; i < sizeof (suffixes); ++i)
+ for (unsigned i = 0; i < sizeof (suffixes) / sizeof (const char *); ++i)
{
- if (strncmp (next_dot + 1, suffixes[i], strlen (suffixes[i])) == 0)
+ int len = strlen (suffixes[i]);
+ if (len == last_dot - next_dot - 1
+ && strncmp (next_dot + 1, suffixes[i], strlen (suffixes[i])) == 0)
{
*next_dot = 0;
return get_original_name (ret, false);