https://gcc.gnu.org/g:4de3524f9e88b7b22bdb481163b05a624f090cf9
commit r16-2124-g4de3524f9e88b7b22bdb481163b05a624f090cf9 Author: Jan Hubicka <hubi...@ucw.cz> Date: Mon Jul 7 17:18:23 2025 +0200 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. Diff: --- gcc/auto-profile.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gcc/auto-profile.cc b/gcc/auto-profile.cc index a970eb8972fa..1700bf8f2cd4 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);