* cgraph.h (symtab_node): (bool needed_p (void)): created from decide_is_symbol_needed (bool referred_to_p (void)): created from referred_to_p (static cgraph_node *get_for_asmname (tree asmname)): created from symtab_node_for_asm * cgraph.h (cgraph_node): (void assemble_thunks_and_aliases (void)): created from assemble_thunks_and_aliases (void expand (void)): created from expand_function (static void finalize_function (tree, bool)): created from cgraph_finalize_function (static cgraph_local_info *local_info (tree decl)): created from cgraph_local_info (static cgraph_global_info *global_info (tree)): created from cgraph_global_info (static cgraph_rtl_info *rtl_info (tree)): created from cgraph_rtl_info * cgraph.h (varpool_node): (static void add (tree decl): created from varpool_add_new_variable * cgraph.h (cgraph_edge): void remove (void); (void remove_caller (void)): created from cgraph_edge_remove_caller (void remove_callee (void)): created from cgraph_edge_remove_callee (void set_call_stmt (gimple new_stmt, bool update_speculative = true)): created from cgraph_set_call_stmt (void redirect_callee (cgraph_node *n)): created from cgraph_redirect_edge_callee (cgraph_edge *make_direct (cgraph_node *callee)): created from cgraph_make_edge_direct (cgraph_edge *make_speculative (cgraph_node *n2, gcov_type direct_count, gimple redirect_call_stmt_to_callee (void)): created from cgraph_turn_edge_to_speculative (void speculative_call_info (cgraph_edge *&direct, cgraph_edge *&indirect, ipa_ref *&reference)): created from cgraph_speculative_call_info (cgraph_edge * clone (cgraph_node *n, gimple call_stmt, unsigned stmt_uid, gcov_type count_scale, int freq_scale, bool update_original)): created from cgraph_clone_edge (cgraph_edge *resolve_speculation (tree callee_decl)): created from cgraph_resolve_speculation (bool cannot_lead_to_return_p (void)): created from cannot_lead_to_return_p (bool recursive_p (void)): created from cgraph_edge_recursive_p (bool maybe_hot_p (void)): created from cgraph_maybe_hot_edge_p (static unsigned int rebuild_edges (void)): created from rebuild_cgraph_edges (static void rebuild_references (void)): created from cgraph_rebuild_references * cgraph.h (symbol_table): (create_reference): renamed from add_reference (maybe_create_reference): renamed from maybe_add_reference (void register_symbol (symtab_node *node)): new function (void clear_asm_symbols (void)): new function (void unregister (symtab_node *node)): new function (void release_symbol (cgraph_node *node, int uid)): new function (cgraph_node * allocate_cgraph_symbol (void)): new function (void initialize (void)): created from cgraph_init (symtab_node *first_symbol (void)):new function (asm_node *first_asm_symbol (void)):new function (symtab_node *first_defined_symbol (void)):new function (varpool_node *first_variable (void)):new function (varpool_node *next_variable (varpool_node *node)):new function (varpool_node *first_static_initializer (void)):new function (varpool_node *next_static_initializer (varpool_node *node)):new function (varpool_node *first_defined_variable (void)):new function (varpool_node *next_defined_variable (varpool_node *node)):new function (cgraph_node *first_defined_function (void)):new function (cgraph_node *next_defined_function (cgraph_node *node)):new function (cgraph_node *first_function (void)):new function (cgraph_node *next_function (cgraph_node *node)):new function (cgraph_node *first_function_with_gimple_body (void)):new function (asm_node *finalize_toplevel_asm (tree asm_str)): created from add_asm_node (bool remove_unreachable_nodes (bool before_inlining_p, FILE *file)): created from symtab_remove_unreachable_nodes (void remove_unreferenced_decls (void)): created from varpool_remove_unreferenced_decls (void process_new_functions (void)): created from cgraph_process_new_functions (void process_same_body_aliases (void)): created from cgraph_process_same_body_aliases (bool output_variables (void)): created from varpool_node::output_variables (void output_asm_statements (void)): created from output_asm_statements (void finalize_compilation_unit (void)): created from finalize_compilation_unit (void compile (void)): created from compile (void output_weakrefs (void)): created from output_weakrefs (cgraph_node *create_empty (void)): created from cgraph_node::create_empty (cgraph_edge *create_edge (cgraph_node *caller, cgraph_node *callee, gimple call_stmt, gcov_type count, int freq, bool indir_unknown_callee)): created from cgraph_node::create_edge (void free_edge (cgraph_edge *e)): created from cgraph_free_edge (cgraph_node *next_function_with_gimple_body (cgraph_node *node)): created from cgraph_next_function_with_gimple_body (void remove_edge_removal_hook (cgraph_edge_hook_list *)): created from cgraph_remove_edge_removal_hook (cgraph_node_hook_list *add_cgraph_removal_hook (cgraph_node_hook, void *)): created from cgraph_add_node_removal_hook (void remove_cgraph_removal_hook (cgraph_node_hook_list *)): created from cgraph_remove_node_removal_hook (varpool_node_hook_list *add_varpool_removal_hook (varpool_node_hook, void *)): created from varpool_add_node_removal_hook (void remove_varpool_removal_hook (varpool_node_hook_list *)): created from varpool_remove_node_removal_hook (cgraph_node_hook_list *add_cgraph_insertion_hook (cgraph_node_hook, void *)): created from cgraph_add_function_insertion_hook (void remove_cgraph_insertion_hook (cgraph_node_hook_list *)): created from cgraph_remove_function_insertion_hook (varpool_node_hook_list *add_varpool_insertion_hook (varpool_node_hook, void *)): created from varpool_add_variable_insertion_hook (void remove_varpool_insertion_hook (varpool_node_hook_list *)): created from varpool_remove_variable_insertion_hook (cgraph_2edge_hook_list *add_edge_duplication_hook (cgraph_2edge_hook, void *)): created from cgraph_add_edge_duplication_hook (void remove_edge_duplication_hook (cgraph_2edge_hook_list *)): created from cgraph_remove_edge_duplication_hook (cgraph_2node_hook_list *add_cgraph_duplication_hook (cgraph_2node_hook, void *)): created from cgraph_add_node_duplication_hook (void remove_cgraph_duplication_hook (cgraph_2node_hook_list *)): created from cgraph_remove_node_duplication_hook (void call_edge_removal_hooks (cgraph_edge *e)): created from cgraph_call_edge_removal_hooks (void call_cgraph_insertion_hooks (cgraph_node *node)): created from call_function_insertion_hooks (void call_cgraph_removal_hooks (cgraph_node *node)): created from cgraph_call_node_removal_hooks (void call_cgraph_duplication_hooks (cgraph_node *node, cgraph_node *node2)): created from cgraph_node::call_duplication_hooks (void call_edge_duplication_hooks (cgraph_edge *cs1, cgraph_edge *cs2)): created from cgraph_call_edge_duplication_hooks (void call_varpool_removal_hooks (varpool_node *node)): created from varpool_call_node_removal_hooks (void call_varpool_insertion_hooks (varpool_node *node)): created from varpool_call_variable_insertion_hooks (void insert_to_assembler_name_hash (symtab_node *node, bool with_clones)): created from insert_to_assembler_name_hash (void unlink_from_assembler_name_hash (symtab_node *node, bool with_clones)): created from unlink_from_assembler_name_hash (void symtab_prevail_in_asm_name_hash (symtab_node *node)): created from symtab_prevail_in_asm_name_hash (void symtab_initialize_asm_name_hash (void)): created from symtab_initialize_asm_name_hash (void change_decl_assembler_name (tree decl, tree name)): created from change_decl_assembler_name (void materialize_all_clones (void)): created from cgraph_materialize_all_clones (static hashval_t decl_assembler_name_hash (const_tree asmname)): created from decl_assembler_name_hash (static bool decl_assembler_name_equal (tree decl, const_tree asmname)): created from decl_assembler_name_equal (static hashval_t hash_node_by_assembler_name (const void *p)): created from hash_node_by_assembler_name (static int eq_assembler_name (const void *p1, const void *p2)): created from eq_assembler_name From-SVN: r214422
579 lines
14 KiB
C
579 lines
14 KiB
C
/* Callgraph construction.
|
|
Copyright (C) 2003-2014 Free Software Foundation, Inc.
|
|
Contributed by Jan Hubicka
|
|
|
|
This file is part of GCC.
|
|
|
|
GCC is free software; you can redistribute it and/or modify it under
|
|
the terms of the GNU General Public License as published by the Free
|
|
Software Foundation; either version 3, or (at your option) any later
|
|
version.
|
|
|
|
GCC is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with GCC; see the file COPYING3. If not see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#include "config.h"
|
|
#include "system.h"
|
|
#include "coretypes.h"
|
|
#include "tm.h"
|
|
#include "tree.h"
|
|
#include "basic-block.h"
|
|
#include "tree-ssa-alias.h"
|
|
#include "internal-fn.h"
|
|
#include "gimple-fold.h"
|
|
#include "gimple-expr.h"
|
|
#include "is-a.h"
|
|
#include "gimple.h"
|
|
#include "gimple-iterator.h"
|
|
#include "gimple-walk.h"
|
|
#include "langhooks.h"
|
|
#include "intl.h"
|
|
#include "tree-pass.h"
|
|
#include "ipa-utils.h"
|
|
#include "except.h"
|
|
#include "ipa-inline.h"
|
|
|
|
/* Context of record_reference. */
|
|
struct record_reference_ctx
|
|
{
|
|
bool only_vars;
|
|
class varpool_node *varpool_node;
|
|
};
|
|
|
|
/* Walk tree and record all calls and references to functions/variables.
|
|
Called via walk_tree: TP is pointer to tree to be examined.
|
|
When DATA is non-null, record references to callgraph.
|
|
*/
|
|
|
|
static tree
|
|
record_reference (tree *tp, int *walk_subtrees, void *data)
|
|
{
|
|
tree t = *tp;
|
|
tree decl;
|
|
record_reference_ctx *ctx = (record_reference_ctx *)data;
|
|
|
|
t = canonicalize_constructor_val (t, NULL);
|
|
if (!t)
|
|
t = *tp;
|
|
else if (t != *tp)
|
|
*tp = t;
|
|
|
|
switch (TREE_CODE (t))
|
|
{
|
|
case VAR_DECL:
|
|
case FUNCTION_DECL:
|
|
gcc_unreachable ();
|
|
break;
|
|
|
|
case FDESC_EXPR:
|
|
case ADDR_EXPR:
|
|
/* Record dereferences to the functions. This makes the
|
|
functions reachable unconditionally. */
|
|
decl = get_base_var (*tp);
|
|
if (TREE_CODE (decl) == FUNCTION_DECL)
|
|
{
|
|
cgraph_node *node = cgraph_node::get_create (decl);
|
|
if (!ctx->only_vars)
|
|
node->mark_address_taken ();
|
|
ctx->varpool_node->create_reference (node, IPA_REF_ADDR);
|
|
}
|
|
|
|
if (TREE_CODE (decl) == VAR_DECL)
|
|
{
|
|
varpool_node *vnode = varpool_node::get_create (decl);
|
|
ctx->varpool_node->create_reference (vnode, IPA_REF_ADDR);
|
|
}
|
|
*walk_subtrees = 0;
|
|
break;
|
|
|
|
default:
|
|
/* Save some cycles by not walking types and declaration as we
|
|
won't find anything useful there anyway. */
|
|
if (IS_TYPE_OR_DECL_P (*tp))
|
|
{
|
|
*walk_subtrees = 0;
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
|
|
return NULL_TREE;
|
|
}
|
|
|
|
/* Record references to typeinfos in the type list LIST. */
|
|
|
|
static void
|
|
record_type_list (cgraph_node *node, tree list)
|
|
{
|
|
for (; list; list = TREE_CHAIN (list))
|
|
{
|
|
tree type = TREE_VALUE (list);
|
|
|
|
if (TYPE_P (type))
|
|
type = lookup_type_for_runtime (type);
|
|
STRIP_NOPS (type);
|
|
if (TREE_CODE (type) == ADDR_EXPR)
|
|
{
|
|
type = TREE_OPERAND (type, 0);
|
|
if (TREE_CODE (type) == VAR_DECL)
|
|
{
|
|
varpool_node *vnode = varpool_node::get_create (type);
|
|
node->create_reference (vnode, IPA_REF_ADDR);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Record all references we will introduce by producing EH tables
|
|
for NODE. */
|
|
|
|
static void
|
|
record_eh_tables (cgraph_node *node, function *fun)
|
|
{
|
|
eh_region i;
|
|
|
|
if (DECL_FUNCTION_PERSONALITY (node->decl))
|
|
{
|
|
tree per_decl = DECL_FUNCTION_PERSONALITY (node->decl);
|
|
cgraph_node *per_node = cgraph_node::get_create (per_decl);
|
|
|
|
node->create_reference (per_node, IPA_REF_ADDR);
|
|
per_node->mark_address_taken ();
|
|
}
|
|
|
|
i = fun->eh->region_tree;
|
|
if (!i)
|
|
return;
|
|
|
|
while (1)
|
|
{
|
|
switch (i->type)
|
|
{
|
|
case ERT_CLEANUP:
|
|
case ERT_MUST_NOT_THROW:
|
|
break;
|
|
|
|
case ERT_TRY:
|
|
{
|
|
eh_catch c;
|
|
for (c = i->u.eh_try.first_catch; c; c = c->next_catch)
|
|
record_type_list (node, c->type_list);
|
|
}
|
|
break;
|
|
|
|
case ERT_ALLOWED_EXCEPTIONS:
|
|
record_type_list (node, i->u.allowed.type_list);
|
|
break;
|
|
}
|
|
/* If there are sub-regions, process them. */
|
|
if (i->inner)
|
|
i = i->inner;
|
|
/* If there are peers, process them. */
|
|
else if (i->next_peer)
|
|
i = i->next_peer;
|
|
/* Otherwise, step back up the tree to the next peer. */
|
|
else
|
|
{
|
|
do
|
|
{
|
|
i = i->outer;
|
|
if (i == NULL)
|
|
return;
|
|
}
|
|
while (i->next_peer == NULL);
|
|
i = i->next_peer;
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Computes the frequency of the call statement so that it can be stored in
|
|
cgraph_edge. BB is the basic block of the call statement. */
|
|
int
|
|
compute_call_stmt_bb_frequency (tree decl, basic_block bb)
|
|
{
|
|
int entry_freq = ENTRY_BLOCK_PTR_FOR_FN
|
|
(DECL_STRUCT_FUNCTION (decl))->frequency;
|
|
int freq = bb->frequency;
|
|
|
|
if (profile_status_for_fn (DECL_STRUCT_FUNCTION (decl)) == PROFILE_ABSENT)
|
|
return CGRAPH_FREQ_BASE;
|
|
|
|
if (!entry_freq)
|
|
entry_freq = 1, freq++;
|
|
|
|
freq = freq * CGRAPH_FREQ_BASE / entry_freq;
|
|
if (freq > CGRAPH_FREQ_MAX)
|
|
freq = CGRAPH_FREQ_MAX;
|
|
|
|
return freq;
|
|
}
|
|
|
|
/* Mark address taken in STMT. */
|
|
|
|
static bool
|
|
mark_address (gimple stmt, tree addr, tree, void *data)
|
|
{
|
|
addr = get_base_address (addr);
|
|
if (TREE_CODE (addr) == FUNCTION_DECL)
|
|
{
|
|
cgraph_node *node = cgraph_node::get_create (addr);
|
|
node->mark_address_taken ();
|
|
((symtab_node *)data)->create_reference (node, IPA_REF_ADDR, stmt);
|
|
}
|
|
else if (addr && TREE_CODE (addr) == VAR_DECL
|
|
&& (TREE_STATIC (addr) || DECL_EXTERNAL (addr)))
|
|
{
|
|
varpool_node *vnode = varpool_node::get_create (addr);
|
|
|
|
((symtab_node *)data)->create_reference (vnode, IPA_REF_ADDR, stmt);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
/* Mark load of T. */
|
|
|
|
static bool
|
|
mark_load (gimple stmt, tree t, tree, void *data)
|
|
{
|
|
t = get_base_address (t);
|
|
if (t && TREE_CODE (t) == FUNCTION_DECL)
|
|
{
|
|
/* ??? This can happen on platforms with descriptors when these are
|
|
directly manipulated in the code. Pretend that it's an address. */
|
|
cgraph_node *node = cgraph_node::get_create (t);
|
|
node->mark_address_taken ();
|
|
((symtab_node *)data)->create_reference (node, IPA_REF_ADDR, stmt);
|
|
}
|
|
else if (t && TREE_CODE (t) == VAR_DECL
|
|
&& (TREE_STATIC (t) || DECL_EXTERNAL (t)))
|
|
{
|
|
varpool_node *vnode = varpool_node::get_create (t);
|
|
|
|
((symtab_node *)data)->create_reference (vnode, IPA_REF_LOAD, stmt);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* Mark store of T. */
|
|
|
|
static bool
|
|
mark_store (gimple stmt, tree t, tree, void *data)
|
|
{
|
|
t = get_base_address (t);
|
|
if (t && TREE_CODE (t) == VAR_DECL
|
|
&& (TREE_STATIC (t) || DECL_EXTERNAL (t)))
|
|
{
|
|
varpool_node *vnode = varpool_node::get_create (t);
|
|
|
|
((symtab_node *)data)->create_reference (vnode, IPA_REF_STORE, stmt);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
/* Record all references from cgraph_node that are taken in statement STMT. */
|
|
|
|
void
|
|
cgraph_node::record_stmt_references (gimple stmt)
|
|
{
|
|
walk_stmt_load_store_addr_ops (stmt, this, mark_load, mark_store,
|
|
mark_address);
|
|
}
|
|
|
|
/* Create cgraph edges for function calls.
|
|
Also look for functions and variables having addresses taken. */
|
|
|
|
namespace {
|
|
|
|
const pass_data pass_data_build_cgraph_edges =
|
|
{
|
|
GIMPLE_PASS, /* type */
|
|
"*build_cgraph_edges", /* name */
|
|
OPTGROUP_NONE, /* optinfo_flags */
|
|
TV_NONE, /* tv_id */
|
|
PROP_cfg, /* properties_required */
|
|
0, /* properties_provided */
|
|
0, /* properties_destroyed */
|
|
0, /* todo_flags_start */
|
|
0, /* todo_flags_finish */
|
|
};
|
|
|
|
class pass_build_cgraph_edges : public gimple_opt_pass
|
|
{
|
|
public:
|
|
pass_build_cgraph_edges (gcc::context *ctxt)
|
|
: gimple_opt_pass (pass_data_build_cgraph_edges, ctxt)
|
|
{}
|
|
|
|
/* opt_pass methods: */
|
|
virtual unsigned int execute (function *);
|
|
|
|
}; // class pass_build_cgraph_edges
|
|
|
|
unsigned int
|
|
pass_build_cgraph_edges::execute (function *fun)
|
|
{
|
|
basic_block bb;
|
|
cgraph_node *node = cgraph_node::get (current_function_decl);
|
|
gimple_stmt_iterator gsi;
|
|
tree decl;
|
|
unsigned ix;
|
|
|
|
/* Create the callgraph edges and record the nodes referenced by the function.
|
|
body. */
|
|
FOR_EACH_BB_FN (bb, fun)
|
|
{
|
|
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
|
{
|
|
gimple stmt = gsi_stmt (gsi);
|
|
tree decl;
|
|
|
|
if (is_gimple_debug (stmt))
|
|
continue;
|
|
|
|
if (is_gimple_call (stmt))
|
|
{
|
|
int freq = compute_call_stmt_bb_frequency (current_function_decl,
|
|
bb);
|
|
decl = gimple_call_fndecl (stmt);
|
|
if (decl)
|
|
node->create_edge (cgraph_node::get_create (decl), stmt, bb->count, freq);
|
|
else if (gimple_call_internal_p (stmt))
|
|
;
|
|
else
|
|
node->create_indirect_edge (stmt,
|
|
gimple_call_flags (stmt),
|
|
bb->count, freq);
|
|
}
|
|
node->record_stmt_references (stmt);
|
|
if (gimple_code (stmt) == GIMPLE_OMP_PARALLEL
|
|
&& gimple_omp_parallel_child_fn (stmt))
|
|
{
|
|
tree fn = gimple_omp_parallel_child_fn (stmt);
|
|
node->create_reference (cgraph_node::get_create (fn),
|
|
IPA_REF_ADDR, stmt);
|
|
}
|
|
if (gimple_code (stmt) == GIMPLE_OMP_TASK)
|
|
{
|
|
tree fn = gimple_omp_task_child_fn (stmt);
|
|
if (fn)
|
|
node->create_reference (cgraph_node::get_create (fn),
|
|
IPA_REF_ADDR, stmt);
|
|
fn = gimple_omp_task_copy_fn (stmt);
|
|
if (fn)
|
|
node->create_reference (cgraph_node::get_create (fn),
|
|
IPA_REF_ADDR, stmt);
|
|
}
|
|
}
|
|
for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
|
node->record_stmt_references (gsi_stmt (gsi));
|
|
}
|
|
|
|
/* Look for initializers of constant variables and private statics. */
|
|
FOR_EACH_LOCAL_DECL (fun, ix, decl)
|
|
if (TREE_CODE (decl) == VAR_DECL
|
|
&& (TREE_STATIC (decl) && !DECL_EXTERNAL (decl))
|
|
&& !DECL_HAS_VALUE_EXPR_P (decl))
|
|
varpool_node::finalize_decl (decl);
|
|
record_eh_tables (node, fun);
|
|
|
|
return 0;
|
|
}
|
|
|
|
} // anon namespace
|
|
|
|
gimple_opt_pass *
|
|
make_pass_build_cgraph_edges (gcc::context *ctxt)
|
|
{
|
|
return new pass_build_cgraph_edges (ctxt);
|
|
}
|
|
|
|
/* Record references to functions and other variables present in the
|
|
initial value of DECL, a variable.
|
|
When ONLY_VARS is true, we mark needed only variables, not functions. */
|
|
|
|
void
|
|
record_references_in_initializer (tree decl, bool only_vars)
|
|
{
|
|
varpool_node *node = varpool_node::get_create (decl);
|
|
hash_set<tree> visited_nodes;
|
|
record_reference_ctx ctx = {false, NULL};
|
|
|
|
ctx.varpool_node = node;
|
|
ctx.only_vars = only_vars;
|
|
walk_tree (&DECL_INITIAL (decl), record_reference,
|
|
&ctx, &visited_nodes);
|
|
}
|
|
|
|
/* Rebuild cgraph edges for current function node. This needs to be run after
|
|
passes that don't update the cgraph. */
|
|
|
|
unsigned int
|
|
cgraph_edge::rebuild_edges (void)
|
|
{
|
|
basic_block bb;
|
|
cgraph_node *node = cgraph_node::get (current_function_decl);
|
|
gimple_stmt_iterator gsi;
|
|
|
|
node->remove_callees ();
|
|
node->remove_all_references ();
|
|
|
|
node->count = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
|
|
|
|
FOR_EACH_BB_FN (bb, cfun)
|
|
{
|
|
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
|
{
|
|
gimple stmt = gsi_stmt (gsi);
|
|
tree decl;
|
|
|
|
if (is_gimple_call (stmt))
|
|
{
|
|
int freq = compute_call_stmt_bb_frequency (current_function_decl,
|
|
bb);
|
|
decl = gimple_call_fndecl (stmt);
|
|
if (decl)
|
|
node->create_edge (cgraph_node::get_create (decl), stmt,
|
|
bb->count, freq);
|
|
else if (gimple_call_internal_p (stmt))
|
|
;
|
|
else
|
|
node->create_indirect_edge (stmt,
|
|
gimple_call_flags (stmt),
|
|
bb->count, freq);
|
|
}
|
|
node->record_stmt_references (stmt);
|
|
}
|
|
for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
|
node->record_stmt_references (gsi_stmt (gsi));
|
|
}
|
|
record_eh_tables (node, cfun);
|
|
gcc_assert (!node->global.inlined_to);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/* Rebuild cgraph references for current function node. This needs to be run
|
|
after passes that don't update the cgraph. */
|
|
|
|
void
|
|
cgraph_edge::rebuild_references (void)
|
|
{
|
|
basic_block bb;
|
|
cgraph_node *node = cgraph_node::get (current_function_decl);
|
|
gimple_stmt_iterator gsi;
|
|
ipa_ref *ref = NULL;
|
|
int i;
|
|
|
|
/* Keep speculative references for further cgraph edge expansion. */
|
|
for (i = 0; node->iterate_reference (i, ref);)
|
|
if (!ref->speculative)
|
|
ref->remove_reference ();
|
|
else
|
|
i++;
|
|
|
|
node->count = ENTRY_BLOCK_PTR_FOR_FN (cfun)->count;
|
|
|
|
FOR_EACH_BB_FN (bb, cfun)
|
|
{
|
|
for (gsi = gsi_start_bb (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
|
node->record_stmt_references (gsi_stmt (gsi));
|
|
for (gsi = gsi_start_phis (bb); !gsi_end_p (gsi); gsi_next (&gsi))
|
|
node->record_stmt_references (gsi_stmt (gsi));
|
|
}
|
|
record_eh_tables (node, cfun);
|
|
}
|
|
|
|
namespace {
|
|
|
|
const pass_data pass_data_rebuild_cgraph_edges =
|
|
{
|
|
GIMPLE_PASS, /* type */
|
|
"*rebuild_cgraph_edges", /* name */
|
|
OPTGROUP_NONE, /* optinfo_flags */
|
|
TV_CGRAPH, /* tv_id */
|
|
PROP_cfg, /* properties_required */
|
|
0, /* properties_provided */
|
|
0, /* properties_destroyed */
|
|
0, /* todo_flags_start */
|
|
0, /* todo_flags_finish */
|
|
};
|
|
|
|
class pass_rebuild_cgraph_edges : public gimple_opt_pass
|
|
{
|
|
public:
|
|
pass_rebuild_cgraph_edges (gcc::context *ctxt)
|
|
: gimple_opt_pass (pass_data_rebuild_cgraph_edges, ctxt)
|
|
{}
|
|
|
|
/* opt_pass methods: */
|
|
opt_pass * clone () { return new pass_rebuild_cgraph_edges (m_ctxt); }
|
|
virtual unsigned int execute (function *)
|
|
{
|
|
return cgraph_edge::rebuild_edges ();
|
|
}
|
|
|
|
}; // class pass_rebuild_cgraph_edges
|
|
|
|
} // anon namespace
|
|
|
|
gimple_opt_pass *
|
|
make_pass_rebuild_cgraph_edges (gcc::context *ctxt)
|
|
{
|
|
return new pass_rebuild_cgraph_edges (ctxt);
|
|
}
|
|
|
|
|
|
namespace {
|
|
|
|
const pass_data pass_data_remove_cgraph_callee_edges =
|
|
{
|
|
GIMPLE_PASS, /* type */
|
|
"*remove_cgraph_callee_edges", /* name */
|
|
OPTGROUP_NONE, /* optinfo_flags */
|
|
TV_NONE, /* tv_id */
|
|
0, /* properties_required */
|
|
0, /* properties_provided */
|
|
0, /* properties_destroyed */
|
|
0, /* todo_flags_start */
|
|
0, /* todo_flags_finish */
|
|
};
|
|
|
|
class pass_remove_cgraph_callee_edges : public gimple_opt_pass
|
|
{
|
|
public:
|
|
pass_remove_cgraph_callee_edges (gcc::context *ctxt)
|
|
: gimple_opt_pass (pass_data_remove_cgraph_callee_edges, ctxt)
|
|
{}
|
|
|
|
/* opt_pass methods: */
|
|
opt_pass * clone () {
|
|
return new pass_remove_cgraph_callee_edges (m_ctxt);
|
|
}
|
|
virtual unsigned int execute (function *);
|
|
|
|
}; // class pass_remove_cgraph_callee_edges
|
|
|
|
unsigned int
|
|
pass_remove_cgraph_callee_edges::execute (function *)
|
|
{
|
|
cgraph_node *node = cgraph_node::get (current_function_decl);
|
|
node->remove_callees ();
|
|
node->remove_all_references ();
|
|
return 0;
|
|
}
|
|
|
|
} // anon namespace
|
|
|
|
gimple_opt_pass *
|
|
make_pass_remove_cgraph_callee_edges (gcc::context *ctxt)
|
|
{
|
|
return new pass_remove_cgraph_callee_edges (ctxt);
|
|
}
|