7de90a6c27
gcc/ * is-a.h: Update comments to reflect the following changes to the "pointerness" of the API, making the template parameter match the return type, allowing use of is-a.h with typedefs of pointers. (is_a_helper::cast): Return a T rather then a pointer to a T, so that the return type matches the parameter to the is_a_helper. (as_a): Likewise. (dyn_cast): Likewise. * cgraph.c (cgraph_node_for_asm): Update for removal of implicit pointer from the is-a.h API. * cgraph.h (is_a_helper <cgraph_node>::test): Convert to... (is_a_helper <cgraph_node *>::test): ...this, matching change to is-a.h API. (is_a_helper <varpool_node>::test): Likewise, convert to... (is_a_helper <varpool_node *>::test): ...this. (varpool_first_variable): Update for removal of implicit pointer from the is-a.h API. (varpool_next_variable): Likewise. (varpool_first_static_initializer): Likewise. (varpool_next_static_initializer): Likewise. (varpool_first_defined_variable): Likewise. (varpool_next_defined_variable): Likewise. (cgraph_first_defined_function): Likewise. (cgraph_next_defined_function): Likewise. (cgraph_first_function): Likewise. (cgraph_next_function): Likewise. (cgraph_first_function_with_gimple_body): Likewise. (cgraph_next_function_with_gimple_body): Likewise. (cgraph_alias_target): Likewise. (varpool_alias_target): Likewise. (cgraph_function_or_thunk_node): Likewise. (varpool_variable_node): Likewise. (symtab_real_symbol_p): Likewise. * cgraphunit.c (referred_to_p): Likewise. (analyze_functions): Likewise. (handle_alias_pairs): Likewise. * gimple-fold.c (can_refer_decl_in_current_unit_p): Likewise. * gimple-ssa.h (gimple_vuse_op): Likewise. (gimple_vdef_op): Likewise. * gimple-streamer-in.c (input_gimple_stmt): Likewise. * gimple.c (gimple_build_asm_1): Likewise. (gimple_build_try): Likewise. (gimple_build_resx): Likewise. (gimple_build_eh_dispatch): Likewise. (gimple_build_omp_for): Likewise. (gimple_omp_for_set_clauses): Likewise. * gimple.h (is_a_helper <gimple_statement_asm>::test): Convert to... (is_a_helper <gimple_statement_asm *>::test): ...this. (is_a_helper <gimple_statement_bind>::test): Convert to... (is_a_helper <gimple_statement_bind *>::test): ...this. (is_a_helper <gimple_statement_call>::test): Convert to... (is_a_helper <gimple_statement_call *>::test): ...this. (is_a_helper <gimple_statement_catch>::test): Convert to... (is_a_helper <gimple_statement_catch *>::test): ...this. (is_a_helper <gimple_statement_resx>::test): Convert to... (is_a_helper <gimple_statement_resx *>::test): ...this. (is_a_helper <gimple_statement_eh_dispatch>::test): Convert to... (is_a_helper <gimple_statement_eh_dispatch *>::test): ...this. (is_a_helper <gimple_statement_eh_else>::test): Convert to... (is_a_helper <gimple_statement_eh_else *>::test): ...this. (is_a_helper <gimple_statement_eh_filter>::test): Convert to... (is_a_helper <gimple_statement_eh_filter *>::test): ...this. (is_a_helper <gimple_statement_eh_mnt>::test): Convert to... (is_a_helper <gimple_statement_eh_mnt *>::test): ...this. (is_a_helper <gimple_statement_omp_atomic_load>::test): Convert to... (is_a_helper <gimple_statement_omp_atomic_load *>::test): ...this. (is_a_helper <gimple_statement_omp_atomic_store>::test): Convert to... (is_a_helper <gimple_statement_omp_atomic_store *>::test): ...this. (is_a_helper <gimple_statement_omp_return>::test): Convert to... (is_a_helper <gimple_statement_omp_return *>::test): ...this. (is_a_helper <gimple_statement_omp_continue>::test): Convert to... (is_a_helper <gimple_statement_omp_continue *>::test): ...this. (is_a_helper <gimple_statement_omp_critical>::test): Convert to... (is_a_helper <gimple_statement_omp_critical *>::test): ...this. (is_a_helper <gimple_statement_omp_for>::test): Convert to... (is_a_helper <gimple_statement_omp_for *>::test): ...this. (is_a_helper <gimple_statement_omp_taskreg>::test): Convert to... (is_a_helper <gimple_statement_omp_taskreg *>::test): ...this. (is_a_helper <gimple_statement_omp_parallel>::test): Convert to... (is_a_helper <gimple_statement_omp_parallel *>::test): ...this. (is_a_helper <gimple_statement_omp_target>::test): Convert to... (is_a_helper <gimple_statement_omp_target *>::test): ...this. (is_a_helper <gimple_statement_omp_sections>::test): Convert to... (is_a_helper <gimple_statement_omp_sections *>::test): ...this. (is_a_helper <gimple_statement_omp_single>::test): Convert to... (is_a_helper <gimple_statement_omp_single *>::test): ...this. (is_a_helper <gimple_statement_omp_teams>::test): Convert to... (is_a_helper <gimple_statement_omp_teams *>::test): ...this. (is_a_helper <gimple_statement_omp_task>::test): Convert to... (is_a_helper <gimple_statement_omp_task *>::test): ...this. (is_a_helper <gimple_statement_phi>::test): Convert to... (is_a_helper <gimple_statement_phi *>::test): ...this. (is_a_helper <gimple_statement_transaction>::test): Convert to... (is_a_helper <gimple_statement_transaction *>::test): ...this. (is_a_helper <gimple_statement_try>::test): Convert to... (is_a_helper <gimple_statement_try *>::test): ...this. (is_a_helper <gimple_statement_wce>::test): Convert to... (is_a_helper <gimple_statement_wce *>::test): ...this. (is_a_helper <const gimple_statement_asm>::test): Convert to... (is_a_helper <const gimple_statement_asm *>::test): ...this. (is_a_helper <const gimple_statement_bind>::test): Convert to... (is_a_helper <const gimple_statement_bind *>::test): ...this. (is_a_helper <const gimple_statement_call>::test): Convert to... (is_a_helper <const gimple_statement_call *>::test): ...this. (is_a_helper <const gimple_statement_catch>::test): Convert to... (is_a_helper <const gimple_statement_catch *>::test): ...this. (is_a_helper <const gimple_statement_resx>::test): Convert to... (is_a_helper <const gimple_statement_resx *>::test): ...this. (is_a_helper <const gimple_statement_eh_dispatch>::test): Convert to... (is_a_helper <const gimple_statement_eh_dispatch *>::test): ...this. (is_a_helper <const gimple_statement_eh_filter>::test): Convert to... (is_a_helper <const gimple_statement_eh_filter *>::test): ...this. (is_a_helper <const gimple_statement_omp_atomic_load>::test): Convert to... (is_a_helper <const gimple_statement_omp_atomic_load *>::test): ...this. (is_a_helper <const gimple_statement_omp_atomic_store>::test): Convert to... (is_a_helper <const gimple_statement_omp_atomic_store *>::test): ...this. (is_a_helper <const gimple_statement_omp_return>::test): Convert to... (is_a_helper <const gimple_statement_omp_return *>::test): ...this. (is_a_helper <const gimple_statement_omp_continue>::test): Convert to... (is_a_helper <const gimple_statement_omp_continue *>::test): ...this. (is_a_helper <const gimple_statement_omp_critical>::test): Convert to... (is_a_helper <const gimple_statement_omp_critical *>::test): ...this. (is_a_helper <const gimple_statement_omp_for>::test): Convert to... (is_a_helper <const gimple_statement_omp_for *>::test): ...this. (is_a_helper <const gimple_statement_omp_taskreg>::test): Convert to... (is_a_helper <const gimple_statement_omp_taskreg *>::test): ...this. (is_a_helper <const gimple_statement_omp_parallel>::test): Convert to... (is_a_helper <const gimple_statement_omp_parallel *>::test): ...this. (is_a_helper <const gimple_statement_omp_target>::test): Convert to... (is_a_helper <const gimple_statement_omp_target *>::test): ...this. (is_a_helper <const gimple_statement_omp_sections>::test): Convert to... (is_a_helper <const gimple_statement_omp_sections *>::test): ...this. (is_a_helper <const gimple_statement_omp_single>::test): Convert to... (is_a_helper <const gimple_statement_omp_single *>::test): ...this. (is_a_helper <const gimple_statement_omp_teams>::test): Convert to... (is_a_helper <const gimple_statement_omp_teams *>::test): ...this. (is_a_helper <const gimple_statement_omp_task>::test): Convert to... (is_a_helper <const gimple_statement_omp_task *>::test): ...this. (is_a_helper <const gimple_statement_phi>::test): Convert to... (is_a_helper <const gimple_statement_phi *>::test): ...this. (is_a_helper <const gimple_statement_transaction>::test): Convert to... (is_a_helper <const gimple_statement_transaction *>::test): ...this. (is_a_helper <const gimple_statement_with_ops>::test): Convert to... (is_a_helper <const gimple_statement_with_ops *>::test): ...this. (is_a_helper <gimple_statement_with_ops>::test): Convert to... (is_a_helper <gimple_statement_with_ops *>::test): ...this. (is_a_helper <const gimple_statement_with_memory_ops>::test): Convert to... (is_a_helper <const gimple_statement_with_memory_ops *>::test): ...this. (is_a_helper <gimple_statement_with_memory_ops>::test): Convert to... (is_a_helper <gimple_statement_with_memory_ops *>::test): ...this. (gimple_use_ops): Update for removal of implicit pointer from the is-a.h API. (gimple_set_use_ops): Likewise. (gimple_vuse): Likewise. (gimple_vdef): Likewise. (gimple_vuse_ptr): Likewise. (gimple_vdef_ptr): Likewise. (gimple_set_vuse): Likewise. (gimple_set_vdef): Likewise. (gimple_omp_return_set_lhs): Likewise. (gimple_omp_return_lhs): Likewise. (gimple_omp_return_lhs_ptr): Likewise. (gimple_call_fntype): Likewise. (gimple_call_set_fntype): Likewise. (gimple_call_set_internal_fn): Likewise. (gimple_call_use_set): Likewise. (gimple_call_clobber_set): Likewise. (gimple_bind_vars): Likewise. (gimple_bind_set_vars): Likewise. (gimple_bind_body_ptr): Likewise. (gimple_bind_set_body): Likewise. (gimple_bind_add_stmt): Likewise. (gimple_bind_block): Likewise. (gimple_bind_set_block): Likewise. (gimple_asm_ninputs): Likewise. (gimple_asm_noutputs): Likewise. (gimple_asm_nclobbers): Likewise. (gimple_asm_nlabels): Likewise. (gimple_asm_input_op): Likewise. (gimple_asm_input_op_ptr): Likewise. (gimple_asm_output_op): Likewise. (gimple_asm_output_op_ptr): Likewise. (gimple_asm_set_output_op): Likewise. (gimple_asm_clobber_op): Likewise. (gimple_asm_set_clobber_op): Likewise. (gimple_asm_label_op): Likewise. (gimple_asm_set_label_op): Likewise. (gimple_asm_string): Likewise. (gimple_catch_types): Likewise. (gimple_catch_types_ptr): Likewise. (gimple_catch_handler_ptr): Likewise. (gimple_catch_set_types): Likewise. (gimple_catch_set_handler): Likewise. (gimple_eh_filter_types): Likewise. (gimple_eh_filter_types_ptr): Likewise. (gimple_eh_filter_failure_ptr): Likewise. (gimple_eh_filter_set_types): Likewise. (gimple_eh_filter_set_failure): Likewise. (gimple_eh_must_not_throw_fndecl): Likewise. (gimple_eh_must_not_throw_set_fndecl): Likewise. (gimple_eh_else_n_body_ptr): Likewise. (gimple_eh_else_e_body_ptr): Likewise. (gimple_eh_else_set_n_body): Likewise. (gimple_eh_else_set_e_body): Likewise. (gimple_try_eval_ptr): Likewise. (gimple_try_cleanup_ptr): Likewise. (gimple_try_set_eval): Likewise. (gimple_try_set_cleanup): Likewise. (gimple_wce_cleanup_ptr): Likewise. (gimple_wce_set_cleanup): Likewise. (gimple_phi_capacity): Likewise. (gimple_phi_num_args): Likewise. (gimple_phi_result): Likewise. (gimple_phi_result_ptr): Likewise. (gimple_phi_set_result): Likewise. (gimple_phi_arg): Likewise. (gimple_phi_set_arg): Likewise. (gimple_resx_region): Likewise. (gimple_resx_set_region): Likewise. (gimple_eh_dispatch_region): Likewise. (gimple_eh_dispatch_set_region): Likewise. (gimple_omp_critical_name): Likewise. (gimple_omp_critical_name_ptr): Likewise. (gimple_omp_critical_set_name): Likewise. (gimple_omp_for_clauses): Likewise. (gimple_omp_for_clauses_ptr): Likewise. (gimple_omp_for_set_clauses): Likewise. (gimple_omp_for_collapse): Likewise. (gimple_omp_for_index): Likewise. (gimple_omp_for_index_ptr): Likewise. (gimple_omp_for_set_index): Likewise. (gimple_omp_for_initial): Likewise. (gimple_omp_for_initial_ptr): Likewise. (gimple_omp_for_set_initial): Likewise. (gimple_omp_for_final): Likewise. (gimple_omp_for_final_ptr): Likewise. (gimple_omp_for_set_final): Likewise. (gimple_omp_for_incr): Likewise. (gimple_omp_for_incr_ptr): Likewise. (gimple_omp_for_set_incr): Likewise. (gimple_omp_for_pre_body_ptr): Likewise. (gimple_omp_for_set_pre_body): Likewise. (gimple_omp_parallel_clauses): Likewise. (gimple_omp_parallel_clauses_ptr): Likewise. (gimple_omp_parallel_set_clauses): Likewise. (gimple_omp_parallel_child_fn): Likewise. (gimple_omp_parallel_child_fn_ptr): Likewise. (gimple_omp_parallel_set_child_fn): Likewise. (gimple_omp_parallel_data_arg): Likewise. (gimple_omp_parallel_data_arg_ptr): Likewise. (gimple_omp_parallel_set_data_arg): Likewise. (gimple_omp_task_clauses): Likewise. (gimple_omp_task_clauses_ptr): Likewise. (gimple_omp_task_set_clauses): Likewise. (gimple_omp_task_child_fn): Likewise. (gimple_omp_task_child_fn_ptr): Likewise. (gimple_omp_task_set_child_fn): Likewise. (gimple_omp_task_data_arg): Likewise. (gimple_omp_task_data_arg_ptr): Likewise. (gimple_omp_task_set_data_arg): Likewise. (gimple_omp_taskreg_clauses): Likewise. (gimple_omp_taskreg_clauses_ptr): Likewise. (gimple_omp_taskreg_set_clauses): Likewise. (gimple_omp_taskreg_child_fn): Likewise. (gimple_omp_taskreg_child_fn_ptr): Likewise. (gimple_omp_taskreg_set_child_fn): Likewise. (gimple_omp_taskreg_data_arg): Likewise. (gimple_omp_taskreg_data_arg_ptr): Likewise. (gimple_omp_taskreg_set_data_arg): Likewise. (gimple_omp_task_copy_fn): Likewise. (gimple_omp_task_copy_fn_ptr): Likewise. (gimple_omp_task_set_copy_fn): Likewise. (gimple_omp_task_arg_size): Likewise. (gimple_omp_task_arg_size_ptr): Likewise. (gimple_omp_task_set_arg_size): Likewise. (gimple_omp_task_arg_align): Likewise. (gimple_omp_task_arg_align_ptr): Likewise. (gimple_omp_task_set_arg_align): Likewise. (gimple_omp_single_clauses): Likewise. (gimple_omp_single_clauses_ptr): Likewise. (gimple_omp_single_set_clauses): Likewise. (gimple_omp_target_clauses): Likewise. (gimple_omp_target_clauses_ptr): Likewise. (gimple_omp_target_set_clauses): Likewise. (gimple_omp_target_child_fn): Likewise. (gimple_omp_target_child_fn_ptr): Likewise. (gimple_omp_target_set_child_fn): Likewise. (gimple_omp_target_data_arg): Likewise. (gimple_omp_target_data_arg_ptr): Likewise. (gimple_omp_target_set_data_arg): Likewise. (gimple_omp_teams_clauses): Likewise. (gimple_omp_teams_clauses_ptr): Likewise. (gimple_omp_teams_set_clauses): Likewise. (gimple_omp_sections_clauses): Likewise. (gimple_omp_sections_clauses_ptr): Likewise. (gimple_omp_sections_set_clauses): Likewise. (gimple_omp_sections_control): Likewise. (gimple_omp_sections_control_ptr): Likewise. (gimple_omp_sections_set_control): Likewise. (gimple_omp_for_set_cond): Likewise. (gimple_omp_for_cond): Likewise. (gimple_omp_atomic_store_set_val): Likewise. (gimple_omp_atomic_store_val): Likewise. (gimple_omp_atomic_store_val_ptr): Likewise. (gimple_omp_atomic_load_set_lhs): Likewise. (gimple_omp_atomic_load_lhs): Likewise. (gimple_omp_atomic_load_lhs_ptr): Likewise. (gimple_omp_atomic_load_set_rhs): Likewise. (gimple_omp_atomic_load_rhs): Likewise. (gimple_omp_atomic_load_rhs_ptr): Likewise. (gimple_omp_continue_control_def): Likewise. (gimple_omp_continue_control_def_ptr): Likewise. (gimple_omp_continue_set_control_def): Likewise. (gimple_omp_continue_control_use): Likewise. (gimple_omp_continue_control_use_ptr): Likewise. (gimple_omp_continue_set_control_use): Likewise. (gimple_transaction_body_ptr): Likewise. (gimple_transaction_label): Likewise. (gimple_transaction_label_ptr): Likewise. (gimple_transaction_set_body): Likewise. (gimple_transaction_set_label): Likewise. * ipa-devirt.c (build_type_inheritance_graph): Likewise. * ipa-inline-analysis.c (inline_write_summary): Likewise. * ipa-ref.c (ipa_record_reference): Likewise. * ipa-reference.c (analyze_function): Likewise. (ipa_reference_write_optimization_summary): Likewise. * ipa.c (symtab_remove_unreachable_nodes): Likewise. (address_taken_from_non_vtable_p): Likewise. (comdat_can_be_unshared_p_1): Likewise. * lto-cgraph.c (lto_output_ref): Likewise. (add_references): Likewise. (compute_ltrans_boundary): Likewise. (output_symtab): Likewise. (input_ref): Likewise. (input_cgraph_1): Likewise. (output_cgraph_opt_summary): Likewise. * lto-streamer-out.c (lto_output): Likewise. (output_symbol_p): Likewise. * lto-streamer.h (lsei_next_function_in_partition): Likewise. (lsei_start_function_in_partition): Likewise. (lsei_next_variable_in_partition): Likewise. (lsei_start_variable_in_partition): Likewise. * symtab.c (insert_to_assembler_name_hash): Likewise. (unlink_from_assembler_name_hash): Likewise. (symtab_unregister_node): Likewise. (symtab_remove_node): Likewise. (dump_symtab_node): Likewise. (verify_symtab_base): Likewise. (verify_symtab_node): Likewise. (symtab_make_decl_local): Likewise. (symtab_alias_ultimate_target): Likewise. (symtab_resolve_alias): Likewise. (symtab_get_symbol_partitioning_class): Likewise. * tree-phinodes.c (allocate_phi_node): Likewise. (reserve_phi_args_for_new_edge): Likewise. (remove_phi_args): Likewise. * varpool.c (varpool_node_for_asm): Likewise. (varpool_remove_unreferenced_decls): Likewise. gcc/lto/ * lto-partition.c (add_references_to_partition): Update for removal of implicit pointer from the is-a.h API. (add_symbol_to_partition_1): Likewise. (contained_in_symbol): Likewise. (undo_partition): Likewise. (lto_balanced_map): Likewise. (promote_symbol): Likewise. * lto-symtab.c (lto_symtab_merge_symbols_1): Likewise. (lto_symtab_merge_symbols): Likewise. * lto.c (lto_wpa_write_files): Likewise. From-SVN: r209719
321 lines
8.7 KiB
C
321 lines
8.7 KiB
C
/* Interprocedural reference lists.
|
|
Copyright (C) 2010-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 "tree.h"
|
|
#include "ggc.h"
|
|
#include "target.h"
|
|
#include "cgraph.h"
|
|
#include "ipa-utils.h"
|
|
|
|
static const char *ipa_ref_use_name[] = {"read","write","addr","alias"};
|
|
|
|
/* Return ipa reference from REFERING_NODE or REFERING_VARPOOL_NODE
|
|
to REFERED_NODE or REFERED_VARPOOL_NODE. USE_TYPE specify type
|
|
of the use and STMT the statement (if it exists). */
|
|
|
|
struct ipa_ref *
|
|
ipa_record_reference (symtab_node *referring_node,
|
|
symtab_node *referred_node,
|
|
enum ipa_ref_use use_type, gimple stmt)
|
|
{
|
|
struct ipa_ref *ref, *ref2;
|
|
struct ipa_ref_list *list, *list2;
|
|
ipa_ref_t *old_references;
|
|
|
|
gcc_checking_assert (!stmt || is_a <cgraph_node *> (referring_node));
|
|
gcc_checking_assert (use_type != IPA_REF_ALIAS || !stmt);
|
|
|
|
list = &referring_node->ref_list;
|
|
old_references = vec_safe_address (list->references);
|
|
vec_safe_grow (list->references, vec_safe_length (list->references) + 1);
|
|
ref = &list->references->last ();
|
|
|
|
list2 = &referred_node->ref_list;
|
|
list2->referring.safe_push (ref);
|
|
ref->referred_index = list2->referring.length () - 1;
|
|
ref->referring = referring_node;
|
|
ref->referred = referred_node;
|
|
ref->stmt = stmt;
|
|
ref->lto_stmt_uid = 0;
|
|
ref->use = use_type;
|
|
ref->speculative = 0;
|
|
|
|
/* If vector was moved in memory, update pointers. */
|
|
if (old_references != list->references->address ())
|
|
{
|
|
int i;
|
|
for (i = 0; ipa_ref_list_reference_iterate (list, i, ref2); i++)
|
|
ipa_ref_referred_ref_list (ref2)->referring[ref2->referred_index] = ref2;
|
|
}
|
|
return ref;
|
|
}
|
|
|
|
/* If VAL is a reference to a function or a variable, add a reference from
|
|
REFERRING_NODE to the corresponding symbol table node. USE_TYPE specify
|
|
type of the use and STMT the statement (if it exists). Return the new
|
|
reference or NULL if none was created. */
|
|
|
|
struct ipa_ref *
|
|
ipa_maybe_record_reference (symtab_node *referring_node, tree val,
|
|
enum ipa_ref_use use_type, gimple stmt)
|
|
{
|
|
STRIP_NOPS (val);
|
|
if (TREE_CODE (val) != ADDR_EXPR)
|
|
return NULL;
|
|
val = get_base_var (val);
|
|
if (val && (TREE_CODE (val) == FUNCTION_DECL
|
|
|| TREE_CODE (val) == VAR_DECL))
|
|
{
|
|
symtab_node *referred = symtab_get_node (val);
|
|
gcc_checking_assert (referred);
|
|
return ipa_record_reference (referring_node, referred,
|
|
use_type, stmt);
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
/* Remove reference REF. */
|
|
|
|
void
|
|
ipa_remove_reference (struct ipa_ref *ref)
|
|
{
|
|
struct ipa_ref_list *list = ipa_ref_referred_ref_list (ref);
|
|
struct ipa_ref_list *list2 = ipa_ref_referring_ref_list (ref);
|
|
vec<ipa_ref_t, va_gc> *old_references = list2->references;
|
|
struct ipa_ref *last;
|
|
|
|
gcc_assert (list->referring[ref->referred_index] == ref);
|
|
last = list->referring.last ();
|
|
if (ref != last)
|
|
{
|
|
list->referring[ref->referred_index] = list->referring.last ();
|
|
list->referring[ref->referred_index]->referred_index
|
|
= ref->referred_index;
|
|
}
|
|
list->referring.pop ();
|
|
|
|
last = &list2->references->last ();
|
|
if (ref != last)
|
|
{
|
|
*ref = *last;
|
|
ipa_ref_referred_ref_list (ref)->referring[ref->referred_index] = ref;
|
|
}
|
|
list2->references->pop ();
|
|
gcc_assert (list2->references == old_references);
|
|
}
|
|
|
|
/* Remove all references in ref list LIST. */
|
|
|
|
void
|
|
ipa_remove_all_references (struct ipa_ref_list *list)
|
|
{
|
|
while (vec_safe_length (list->references))
|
|
ipa_remove_reference (&list->references->last ());
|
|
vec_free (list->references);
|
|
}
|
|
|
|
/* Remove all references in ref list LIST. */
|
|
|
|
void
|
|
ipa_remove_all_referring (struct ipa_ref_list *list)
|
|
{
|
|
while (list->referring.length ())
|
|
ipa_remove_reference (list->referring.last ());
|
|
list->referring.release ();
|
|
}
|
|
|
|
/* Dump references in LIST to FILE. */
|
|
|
|
void
|
|
ipa_dump_references (FILE * file, struct ipa_ref_list *list)
|
|
{
|
|
struct ipa_ref *ref;
|
|
int i;
|
|
for (i = 0; ipa_ref_list_reference_iterate (list, i, ref); i++)
|
|
{
|
|
fprintf (file, "%s/%i (%s)",
|
|
ref->referred->asm_name (),
|
|
ref->referred->order,
|
|
ipa_ref_use_name [ref->use]);
|
|
if (ref->speculative)
|
|
fprintf (file, " (speculative)");
|
|
}
|
|
fprintf (file, "\n");
|
|
}
|
|
|
|
/* Dump referring in LIST to FILE. */
|
|
|
|
void
|
|
ipa_dump_referring (FILE * file, struct ipa_ref_list *list)
|
|
{
|
|
struct ipa_ref *ref;
|
|
int i;
|
|
for (i = 0; ipa_ref_list_referring_iterate (list, i, ref); i++)
|
|
{
|
|
fprintf (file, "%s/%i (%s)",
|
|
ref->referring->asm_name (),
|
|
ref->referring->order,
|
|
ipa_ref_use_name [ref->use]);
|
|
if (ref->speculative)
|
|
fprintf (file, " (speculative)");
|
|
}
|
|
fprintf (file, "\n");
|
|
}
|
|
|
|
/* Clone reference REF to DEST_NODE and set its stmt to STMT. */
|
|
|
|
struct ipa_ref *
|
|
ipa_clone_ref (struct ipa_ref *ref,
|
|
symtab_node *dest_node,
|
|
gimple stmt)
|
|
{
|
|
bool speculative = ref->speculative;
|
|
unsigned int stmt_uid = ref->lto_stmt_uid;
|
|
struct ipa_ref *ref2;
|
|
|
|
ref2 = ipa_record_reference (dest_node,
|
|
ref->referred,
|
|
ref->use, stmt);
|
|
ref2->speculative = speculative;
|
|
ref2->lto_stmt_uid = stmt_uid;
|
|
return ref2;
|
|
}
|
|
|
|
/* Clone all references from SRC to DEST_NODE or DEST_VARPOOL_NODE. */
|
|
|
|
void
|
|
ipa_clone_references (symtab_node *dest_node,
|
|
struct ipa_ref_list *src)
|
|
{
|
|
struct ipa_ref *ref, *ref2;
|
|
int i;
|
|
for (i = 0; ipa_ref_list_reference_iterate (src, i, ref); i++)
|
|
{
|
|
bool speculative = ref->speculative;
|
|
unsigned int stmt_uid = ref->lto_stmt_uid;
|
|
|
|
ref2 = ipa_record_reference (dest_node,
|
|
ref->referred,
|
|
ref->use, ref->stmt);
|
|
ref2->speculative = speculative;
|
|
ref2->lto_stmt_uid = stmt_uid;
|
|
}
|
|
}
|
|
|
|
/* Clone all referring from SRC to DEST_NODE or DEST_VARPOOL_NODE. */
|
|
|
|
void
|
|
ipa_clone_referring (symtab_node *dest_node,
|
|
struct ipa_ref_list *src)
|
|
{
|
|
struct ipa_ref *ref, *ref2;
|
|
int i;
|
|
for (i = 0; ipa_ref_list_referring_iterate (src, i, ref); i++)
|
|
{
|
|
bool speculative = ref->speculative;
|
|
unsigned int stmt_uid = ref->lto_stmt_uid;
|
|
|
|
ref2 = ipa_record_reference (ref->referring,
|
|
dest_node,
|
|
ref->use, ref->stmt);
|
|
ref2->speculative = speculative;
|
|
ref2->lto_stmt_uid = stmt_uid;
|
|
}
|
|
}
|
|
|
|
/* Return true when execution of REF can lead to return from
|
|
function. */
|
|
bool
|
|
ipa_ref_cannot_lead_to_return (struct ipa_ref *ref)
|
|
{
|
|
return cgraph_node_cannot_return (ipa_ref_referring_node (ref));
|
|
}
|
|
|
|
/* Return true if list contains an alias. */
|
|
bool
|
|
ipa_ref_has_aliases_p (struct ipa_ref_list *ref_list)
|
|
{
|
|
struct ipa_ref *ref;
|
|
int i;
|
|
|
|
for (i = 0; ipa_ref_list_referring_iterate (ref_list, i, ref); i++)
|
|
if (ref->use == IPA_REF_ALIAS)
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
/* Find the structure describing a reference in REFERRING_NODE to REFERRED_NODE
|
|
and associated with statement STMT. */
|
|
|
|
struct ipa_ref *
|
|
ipa_find_reference (symtab_node *referring_node, symtab_node *referred_node,
|
|
gimple stmt, unsigned int lto_stmt_uid)
|
|
{
|
|
struct ipa_ref *r = NULL;
|
|
int i;
|
|
|
|
for (i = 0; ipa_ref_list_reference_iterate (&referring_node->ref_list, i, r); i++)
|
|
if (r->referred == referred_node
|
|
&& !r->speculative
|
|
&& ((stmt && r->stmt == stmt)
|
|
|| (lto_stmt_uid && r->lto_stmt_uid == lto_stmt_uid)
|
|
|| (!stmt && !lto_stmt_uid && !r->stmt && !r->lto_stmt_uid)))
|
|
return r;
|
|
return NULL;
|
|
}
|
|
|
|
/* Remove all references from REFERRING_NODE that are associated with statement
|
|
STMT. */
|
|
|
|
void
|
|
ipa_remove_stmt_references (symtab_node *referring_node, gimple stmt)
|
|
{
|
|
struct ipa_ref *r = NULL;
|
|
int i = 0;
|
|
|
|
while (ipa_ref_list_reference_iterate (&referring_node->ref_list, i, r))
|
|
if (r->stmt == stmt)
|
|
ipa_remove_reference (r);
|
|
else
|
|
i++;
|
|
}
|
|
|
|
/* Remove all stmt references in non-speculative references.
|
|
Those are not maintained during inlining & clonning.
|
|
The exception are speculative references that are updated along
|
|
with callgraph edges associated with them. */
|
|
|
|
void
|
|
ipa_clear_stmts_in_references (symtab_node *referring_node)
|
|
{
|
|
struct ipa_ref *r = NULL;
|
|
int i;
|
|
|
|
for (i = 0; ipa_ref_list_reference_iterate (&referring_node->ref_list, i, r); i++)
|
|
if (!r->speculative)
|
|
{
|
|
r->stmt = NULL;
|
|
r->lto_stmt_uid = 0;
|
|
}
|
|
}
|