diff options
author | Michael Ploujnikov <michael.ploujnikov@oracle.com> | 2018-10-30 11:39:29 +0000 |
---|---|---|
committer | Martin Liska <marxin@gcc.gnu.org> | 2018-10-30 11:39:29 +0000 |
commit | 7958186bea8d900b8e876f80c2b089581e717cdc (patch) | |
tree | f97eaee1050aed32973ba14c4ca333e316d141a8 /gcc/cgraphclones.c | |
parent | 29f6f2d244c77dd7ae5a86b3bf7cb18fd953168f (diff) | |
download | gcc-7958186bea8d900b8e876f80c2b089581e717cdc.zip gcc-7958186bea8d900b8e876f80c2b089581e717cdc.tar.gz gcc-7958186bea8d900b8e876f80c2b089581e717cdc.tar.bz2 |
Avoid unnecessarily numbering cloned symbols.
2018-10-30 Michael Ploujnikov <michael.ploujnikov@oracle.com>
* cgraph.h (clone_function_name_1): Replaced by new
clone_function_name_numbered that takes name as string; for
privatize_symbol_name_1 use only.
(clone_function_name): Renamed to
clone_function_name_numbered to be explicit about numbering.
(clone_function_name): New two-argument function that does
not number its output.
(clone_function_name): New three-argument function that
takes a number to append to its output.
* cgraphclones.c (duplicate_thunk_for_node):
(clone_function_name_1): Renamed.
(clone_function_name_numbered): Two new functions.
(clone_function_name): Improved documentation.
(cgraph_node::create_virtual_clone): Use clone_function_name_numbered.
* config/rs6000/rs6000.c (make_resolver_func): Ditto.
* final.c (final_scan_insn_1): Use the new clone_function_name
without numbering.
* multiple_target.c (create_dispatcher_calls): Ditto.
(create_target_clone): Ditto.
* omp-expand.c (grid_expand_target_grid_body): Ditto.
* omp-low.c (create_omp_child_function_name): Ditto.
* omp-simd-clone.c (simd_clone_create): Ditto.
* symtab.c (simd_symtab_node::noninterposable_alias): Use the
new clone_function_name without numbering.
2018-10-30 Michael Ploujnikov <michael.ploujnikov@oracle.com>
* lto-partition.c (privatize_symbol_name_1): Use
clone_function_name_numbered.
2018-10-30 Michael Ploujnikov <michael.ploujnikov@oracle.com>
* gcc.dg/tree-prof/cold_partition_label.c: Update for cold
section names without numbers.
* gcc.dg/tree-prof/section-attr-1.c: Ditto.
* gcc.dg/tree-prof/section-attr-2.c: Ditto.
* gcc.dg/tree-prof/section-attr-3.c: Ditto.
From-SVN: r265621
Diffstat (limited to 'gcc/cgraphclones.c')
-rw-r--r-- | gcc/cgraphclones.c | 69 |
1 files changed, 59 insertions, 10 deletions
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c index 189cb31..e17959c 100644 --- a/gcc/cgraphclones.c +++ b/gcc/cgraphclones.c @@ -317,7 +317,8 @@ duplicate_thunk_for_node (cgraph_node *thunk, cgraph_node *node) gcc_checking_assert (!DECL_RESULT (new_decl)); gcc_checking_assert (!DECL_RTL_SET_P (new_decl)); - DECL_NAME (new_decl) = clone_function_name (thunk->decl, "artificial_thunk"); + DECL_NAME (new_decl) = clone_function_name_numbered (thunk->decl, + "artificial_thunk"); SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl)); new_thunk = cgraph_node::create (new_decl); @@ -514,11 +515,41 @@ cgraph_node::create_clone (tree new_decl, profile_count prof_count, static GTY(()) unsigned int clone_fn_id_num; -/* Return a new assembler name for a clone with SUFFIX of a decl named - NAME. */ +/* Return a new assembler name for a clone of decl named NAME. Apart + from the string SUFFIX, the new name will end with a unique (for + each NAME) unspecified number. If clone numbering is not needed + then the two argument clone_function_name should be used instead. + Should not be called directly except for by + lto-partition.c:privatize_symbol_name_1. */ tree -clone_function_name_1 (const char *name, const char *suffix) +clone_function_name_numbered (const char *name, const char *suffix) +{ + return clone_function_name (name, suffix, clone_fn_id_num++); +} + +/* Return a new assembler name for a clone of DECL. Apart from string + SUFFIX, the new name will end with a unique (for each DECL + assembler name) unspecified number. If clone numbering is not + needed then the two argument clone_function_name should be used + instead. */ + +tree +clone_function_name_numbered (tree decl, const char *suffix) +{ + tree name = DECL_ASSEMBLER_NAME (decl); + return clone_function_name_numbered (IDENTIFIER_POINTER (name), + suffix); +} + +/* Return a new assembler name for a clone of decl named NAME. Apart + from the string SUFFIX, the new name will end with the specified + NUMBER. If clone numbering is not needed then the two argument + clone_function_name should be used instead. */ + +tree +clone_function_name (const char *name, const char *suffix, + unsigned long number) { size_t len = strlen (name); char *tmp_name, *prefix; @@ -527,17 +558,34 @@ clone_function_name_1 (const char *name, const char *suffix) memcpy (prefix, name, len); strcpy (prefix + len + 1, suffix); prefix[len] = symbol_table::symbol_suffix_separator (); - ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix, clone_fn_id_num++); + ASM_FORMAT_PRIVATE_NAME (tmp_name, prefix, number); return get_identifier (tmp_name); } -/* Return a new assembler name for a clone of DECL with SUFFIX. */ +/* Return a new assembler name ending with the string SUFFIX for a + clone of DECL. */ tree clone_function_name (tree decl, const char *suffix) { - tree name = DECL_ASSEMBLER_NAME (decl); - return clone_function_name_1 (IDENTIFIER_POINTER (name), suffix); + tree identifier = DECL_ASSEMBLER_NAME (decl); + /* For consistency this needs to behave the same way as + ASM_FORMAT_PRIVATE_NAME does, but without the final number + suffix. */ + char *separator = XALLOCAVEC (char, 2); + separator[0] = symbol_table::symbol_suffix_separator (); + separator[1] = 0; +#if defined (NO_DOT_IN_LABEL) && defined (NO_DOLLAR_IN_LABEL) + const char *prefix = "__"; +#else + const char *prefix = ""; +#endif + char *result = ACONCAT ((prefix, + IDENTIFIER_POINTER (identifier), + separator, + suffix, + (char*)0)); + return get_identifier (result); } @@ -585,7 +633,8 @@ cgraph_node::create_virtual_clone (vec<cgraph_edge *> redirect_callers, strcpy (name + len + 1, suffix); name[len] = '.'; DECL_NAME (new_decl) = get_identifier (name); - SET_DECL_ASSEMBLER_NAME (new_decl, clone_function_name (old_decl, suffix)); + SET_DECL_ASSEMBLER_NAME (new_decl, clone_function_name_numbered (old_decl, + suffix)); SET_DECL_RTL (new_decl, NULL); new_node = create_clone (new_decl, count, false, @@ -964,7 +1013,7 @@ cgraph_node::create_version_clone_with_body = build_function_decl_skip_args (old_decl, args_to_skip, skip_return); /* Generate a new name for the new version. */ - DECL_NAME (new_decl) = clone_function_name (old_decl, suffix); + DECL_NAME (new_decl) = clone_function_name_numbered (old_decl, suffix); SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl)); SET_DECL_RTL (new_decl, NULL); |