-void
-init_cgraph (void)
-{
- if (!cgraph_dump_file)
- cgraph_dump_file = dump_begin (TDI_cgraph, NULL);
-}
-
-/* The edges representing the callers of the NEW_VERSION node were
- fixed by cgraph_function_versioning (), now the call_expr in their
- respective tree code should be updated to call the NEW_VERSION. */
-
-static void
-update_call_expr (struct cgraph_node *new_version)
-{
- struct cgraph_edge *e;
-
- gcc_assert (new_version);
-
- /* Update the call expr on the edges to call the new version. */
- for (e = new_version->callers; e; e = e->next_caller)
- {
- struct function *inner_function = DECL_STRUCT_FUNCTION (e->caller->decl);
- gimple_call_set_fndecl (e->call_stmt, new_version->decl);
- maybe_clean_eh_stmt_fn (inner_function, e->call_stmt);
- }
-}
-
-
-/* Create a new cgraph node which is the new version of
- OLD_VERSION node. REDIRECT_CALLERS holds the callers
- edges which should be redirected to point to
- NEW_VERSION. ALL the callees edges of OLD_VERSION
- are cloned to the new version node. Return the new
- version node.
-
- If non-NULL BLOCK_TO_COPY determine what basic blocks
- was copied to prevent duplications of calls that are dead
- in the clone. */
-
-static struct cgraph_node *
-cgraph_copy_node_for_versioning (struct cgraph_node *old_version,
- tree new_decl,
- VEC(cgraph_edge_p,heap) *redirect_callers,
- bitmap bbs_to_copy)
- {
- struct cgraph_node *new_version;
- struct cgraph_edge *e;
- unsigned i;
-
- gcc_assert (old_version);
-
- new_version = cgraph_create_node (new_decl);
-
- new_version->analyzed = true;
- new_version->local = old_version->local;
- new_version->local.externally_visible = false;
- new_version->local.local = true;
- new_version->global = old_version->global;
- new_version->rtl = old_version->rtl;
- new_version->reachable = true;
- new_version->count = old_version->count;
-
- for (e = old_version->callees; e; e=e->next_callee)
- if (!bbs_to_copy
- || bitmap_bit_p (bbs_to_copy, gimple_bb (e->call_stmt)->index))
- cgraph_clone_edge (e, new_version, e->call_stmt,
- e->lto_stmt_uid, REG_BR_PROB_BASE,
- CGRAPH_FREQ_BASE,
- e->loop_nest, true);
- for (e = old_version->indirect_calls; e; e=e->next_callee)
- if (!bbs_to_copy
- || bitmap_bit_p (bbs_to_copy, gimple_bb (e->call_stmt)->index))
- cgraph_clone_edge (e, new_version, e->call_stmt,
- e->lto_stmt_uid, REG_BR_PROB_BASE,
- CGRAPH_FREQ_BASE,
- e->loop_nest, true);
- FOR_EACH_VEC_ELT (cgraph_edge_p, redirect_callers, i, e)
- {
- /* Redirect calls to the old version node to point to its new
- version. */
- cgraph_redirect_edge_callee (e, new_version);
- }
-
- return new_version;
- }
-
- /* Perform function versioning.
- Function versioning includes copying of the tree and
- a callgraph update (creating a new cgraph node and updating
- its callees and callers).
-
- REDIRECT_CALLERS varray includes the edges to be redirected
- to the new version.
-
- TREE_MAP is a mapping of tree nodes we want to replace with
- new ones (according to results of prior analysis).
- OLD_VERSION_NODE is the node that is versioned.
- It returns the new version's cgraph node.
- If non-NULL ARGS_TO_SKIP determine function parameters to remove
- from new version.
- If non-NULL BLOCK_TO_COPY determine what basic blocks to copy.
- If non_NULL NEW_ENTRY determine new entry BB of the clone. */
-
-struct cgraph_node *
-cgraph_function_versioning (struct cgraph_node *old_version_node,
- VEC(cgraph_edge_p,heap) *redirect_callers,
- VEC (ipa_replace_map_p,gc)* tree_map,
- bitmap args_to_skip,
- bitmap bbs_to_copy,
- basic_block new_entry_block,
- const char *clone_name)
-{
- tree old_decl = old_version_node->decl;
- struct cgraph_node *new_version_node = NULL;
- tree new_decl;
-
- if (!tree_versionable_function_p (old_decl))
- return NULL;
-
- gcc_assert (old_version_node->local.can_change_signature || !args_to_skip);