aboutsummaryrefslogtreecommitdiff
path: root/gcc/cgraphclones.c
diff options
context:
space:
mode:
authorMichael Ploujnikov <michael.ploujnikov@oracle.com>2018-11-30 22:27:11 +0000
committerMichael Ploujnikov <plouj@gcc.gnu.org>2018-11-30 22:27:11 +0000
commit53aedcce09b10467e60b9717223191f28e0360a3 (patch)
treec72d1dda4f4a1aa9ddf8b49d3b4e9c31949ec228 /gcc/cgraphclones.c
parentb75255a9b11ae672e569966860090d70ff10ffca (diff)
downloadgcc-53aedcce09b10467e60b9717223191f28e0360a3.zip
gcc-53aedcce09b10467e60b9717223191f28e0360a3.tar.gz
gcc-53aedcce09b10467e60b9717223191f28e0360a3.tar.bz2
Minimize clone counter memory usage in create_virtual_clone.
Based on Martin Jambour's suggestion: https://gcc.gnu.org/ml/gcc-patches/2018-09/msg00111.html gcc: * cgraph.h (clone_function_name): Add a variant that takes a tree decl. * cgraph.h (cgraph_node::create_virtual_clone): Add a new argument: num_suffix. * cgraphclones.c (cgraph_node::create_virtual_clone): Pass num_suffix to clone_function_name. (clone_function_name): Add a variant that takes a tree decl. * ipa-cp.c (create_specialized_node): Keep track of clone counters in clone_num_suffixes hash map. (ipcp_driver): Free the counter hash map. * ipa-hsa.c (process_hsa_functions): Creates at most one hsa clone per function. From-SVN: r266692
Diffstat (limited to 'gcc/cgraphclones.c')
-rw-r--r--gcc/cgraphclones.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/gcc/cgraphclones.c b/gcc/cgraphclones.c
index a45722f..f807692 100644
--- a/gcc/cgraphclones.c
+++ b/gcc/cgraphclones.c
@@ -572,6 +572,19 @@ clone_function_name (const char *name, const char *suffix,
return get_identifier (tmp_name);
}
+/* Return a new assembler name for a clone of DECL. 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 (tree decl, const char *suffix,
+ unsigned long number)
+{
+ return clone_function_name (
+ IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), suffix, number);
+}
+
/* Return a new assembler name ending with the string SUFFIX for a
clone of DECL. */
@@ -599,8 +612,9 @@ clone_function_name (tree decl, const char *suffix)
}
-/* Create callgraph node clone with new declaration. The actual body will
- be copied later at compilation stage.
+/* 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.
TODO: after merging in ipa-sra use function call notes instead of args_to_skip
bitmap interface.
@@ -608,7 +622,8 @@ clone_function_name (tree decl, const char *suffix)
cgraph_node *
cgraph_node::create_virtual_clone (vec<cgraph_edge *> redirect_callers,
vec<ipa_replace_map *, va_gc> *tree_map,
- bitmap args_to_skip, const char * suffix)
+ bitmap args_to_skip, const char * suffix,
+ unsigned num_suffix)
{
tree old_decl = decl;
cgraph_node *new_node = NULL;
@@ -643,8 +658,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_numbered (old_decl,
- suffix));
+ SET_DECL_ASSEMBLER_NAME (new_decl,
+ clone_function_name (old_decl, suffix, num_suffix));
SET_DECL_RTL (new_decl, NULL);
new_node = create_clone (new_decl, count, false,