https://gcc.gnu.org/g:93a83a8e51a92699948ba322c22d071e89d0eedf
commit 93a83a8e51a92699948ba322c22d071e89d0eedf Author: Alfie Richards <alfie.richa...@arm.com> Date: Fri Jan 31 11:47:57 2025 +0000 Add clone_identifier function. This is similar to clone_function_name and its siblings but takes an identifier tree node rather than a function declaration. This is to be used in conjunction with the identifier node stored in cgraph_function_version_info::assembler_name to mangle FMV functions in later patches. gcc/ChangeLog: * cgraph.h (clone_identifier): New function. * cgraphclones.cc (clone_identifier): New function. clone_function_name: Refactored to use clone_identifier. Diff: --- gcc/cgraph.h | 1 + gcc/cgraphclones.cc | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/gcc/cgraph.h b/gcc/cgraph.h index 91e5de30f98c..8dcc9315a51a 100644 --- a/gcc/cgraph.h +++ b/gcc/cgraph.h @@ -2629,6 +2629,7 @@ tree clone_function_name (const char *name, const char *suffix, tree clone_function_name (tree decl, const char *suffix, unsigned long number); tree clone_function_name (tree decl, const char *suffix); +tree clone_identifier (tree decl, const char *suffix); void tree_function_versioning (tree, tree, vec<ipa_replace_map *, va_gc> *, ipa_param_adjustments *, diff --git a/gcc/cgraphclones.cc b/gcc/cgraphclones.cc index 5332a4333173..6b650849a63c 100644 --- a/gcc/cgraphclones.cc +++ b/gcc/cgraphclones.cc @@ -557,6 +557,14 @@ clone_function_name (tree decl, const char *suffix) /* For consistency this needs to behave the same way as ASM_FORMAT_PRIVATE_NAME does, but without the final number suffix. */ + return clone_identifier (identifier, suffix); +} + +/* Return a new clone of ID ending with the string SUFFIX. */ + +tree +clone_identifier (tree id, const char *suffix) +{ char *separator = XALLOCAVEC (char, 2); separator[0] = symbol_table::symbol_suffix_separator (); separator[1] = 0; @@ -565,15 +573,11 @@ clone_function_name (tree decl, const char *suffix) #else const char *prefix = ""; #endif - char *result = ACONCAT ((prefix, - IDENTIFIER_POINTER (identifier), - separator, - suffix, - (char*)0)); + char *result = ACONCAT ( + (prefix, IDENTIFIER_POINTER (id), separator, suffix, (char *) 0)); return get_identifier (result); } - /* Create callgraph node clone with new declaration. The actual body will be copied later at compilation stage. The name of the new clone will be constructed from the name of the original node, SUFFIX and NUM_SUFFIX.