+2018-11-30 Michael Ploujnikov <michael.ploujnikov@oracle.com>
+
+ Minimize clone counter memory usage in create_virtual_clone.
+ * 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.
+
2018-11-30 Michael Ploujnikov <michael.ploujnikov@oracle.com>
Make function assembly more independent.
cgraph_node *new_inlined_to,
bitmap args_to_skip, const char *suffix = NULL);
- /* 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. */
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);
/* cgraph node being removed from symbol table; see if its entry can be
replaced by other inline clone. */
tree clone_function_name_numbered (tree decl, const char *suffix);
tree clone_function_name (const char *name, const char *suffix,
unsigned long number);
+tree clone_function_name (tree decl, const char *suffix,
+ unsigned long number);
tree clone_function_name (tree decl, const char *suffix);
void tree_function_versioning (tree, tree, vec<ipa_replace_map *, va_gc> *,
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. */
}
-/* 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.
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;
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,
static long overall_size, max_new_size;
+/* Node to unique clone suffix number map. */
+static hash_map<cgraph_node *, unsigned> *clone_num_suffixes;
+
/* Return the param lattices structure corresponding to the Ith formal
parameter of the function described by INFO. */
static inline struct ipcp_param_lattices *
}
}
+ unsigned &suffix_counter = clone_num_suffixes->get_or_insert (node);
new_node = node->create_virtual_clone (callers, replace_trees,
- args_to_skip, "constprop");
+ args_to_skip, "constprop",
+ suffix_counter);
+ suffix_counter++;
bool have_self_recursive_calls = !self_recursive_calls.is_empty ();
for (unsigned j = 0; j < self_recursive_calls.length (); j++)
ipa_check_create_node_params ();
ipa_check_create_edge_args ();
+ clone_num_suffixes = new hash_map<cgraph_node *, unsigned>;
if (dump_file)
{
ipcp_store_vr_results ();
/* Free all IPCP structures. */
+ delete clone_num_suffixes;
free_toporder_info (&topo);
delete edge_clone_summaries;
edge_clone_summaries = NULL;
continue;
cgraph_node *clone
= node->create_virtual_clone (vec <cgraph_edge *> (),
- NULL, NULL, "hsa");
+ NULL, NULL, "hsa", 0);
TREE_PUBLIC (clone->decl) = TREE_PUBLIC (node->decl);
clone->externally_visible = node->externally_visible;
continue;
cgraph_node *clone
= node->create_virtual_clone (vec <cgraph_edge *> (),
- NULL, NULL, "hsa");
+ NULL, NULL, "hsa", 0);
TREE_PUBLIC (clone->decl) = TREE_PUBLIC (node->decl);
clone->externally_visible = node->externally_visible;