GCC Middle and Back End API Reference
|
Go to the source code of this file.
Data Structures | |
struct | copy_body_data |
struct | eni_weights |
Typedefs | |
typedef int_hash< unsigned short, 0 > | dependence_hash |
Enumerations | |
enum | copy_body_cge_which { CB_CGE_DUPLICATE , CB_CGE_MOVE , CB_CGE_MOVE_CLONES } |
Variables | |
eni_weights | eni_inlining_weights |
eni_weights | eni_size_weights |
eni_weights | eni_time_weights |
typedef int_hash<unsigned short, 0> dependence_hash |
enum copy_body_cge_which |
This is in tree-inline.cc since the routine uses data structures from the inliner.
Duplicate a type, fields and all.
References cfun, copy_decl_no_change(), current_function_decl, copy_body_data::debug_map, NULL, remap_type_1(), type(), and TYPE_CANONICAL.
|
extern |
Copy NODE (which must be a DECL). The DECL originally was in the FROM_FN, but now it will be in the TO_FN. PARM_TO_VAR means enable PARM_DECL to VAR_DECL translation.
References DECL_ABSTRACT_ORIGIN, DECL_ARTIFICIAL, DECL_ATTRIBUTES, DECL_CONTEXT, DECL_EXTERNAL, DECL_IGNORED_P, DECL_ORIGIN, get_identifier(), HAS_RTL_P, is_gimple_reg(), lookup_attribute(), NULL, SET_DECL_MODE, SET_DECL_RTL, tree_cons(), TREE_STATIC, TREE_TYPE, TREE_USED, TYPE_MODE, VAR_P, and VECTOR_TYPE_P.
Referenced by assumption_copy_decl(), copy_decl_no_change(), copy_decl_to_var(), copy_result_decl_to_var(), and create_asan_shadow_var().
tree copy_decl_no_change | ( | tree | decl, |
copy_body_data * | id ) |
References copy_decl_for_dup_finish(), copy_node(), DECL_ABSTRACT_P, lang_hooks::dup_lang_specific_decl, LABEL_DECL_UID, TREE_ADDRESSABLE, and TREE_CODE.
Referenced by build_duplicate_type(), copy_decl_maybe_to_var(), copy_fn(), copy_gimple_seq_and_replace_locals(), gimplify_omp_loop(), maybe_inline_call_in_expr(), nesting_copy_decl(), and tree_function_versioning().
|
extern |
Create a new VAR_DECL that is indentical in all respect to DECL except that DECL can be either a VAR_DECL, a PARM_DECL or RESULT_DECL. The original DECL must come from ID->src_fn and the copy will be part of ID->dst_fn.
References build_decl(), copy_decl_for_dup_finish(), DECL_BY_REFERENCE, DECL_NAME, DECL_NOT_GIMPLE_REG_P, DECL_PT_UID, DECL_PT_UID_SET_P, DECL_SOURCE_LOCATION, gcc_assert, SET_DECL_PT_UID, TREE_ADDRESSABLE, TREE_CODE, TREE_READONLY, TREE_THIS_VOLATILE, TREE_TYPE, and type().
Referenced by ipa_param_body_adjustments::common_initialization(), copy_decl_maybe_to_var(), and setup_one_parameter().
Unshare the entire DECL_SAVED_TREE of FN and return the remapped parameters and RESULT_DECL in PARMS and RESULT. Used by C++ constexpr evaluation.
References CB_CGE_DUPLICATE, copy_decl_no_change(), copy_tree_body(), current_function_decl, DECL_ARGUMENTS, DECL_CHAIN, copy_body_data::decl_map, DECL_RESULT, DECL_STRUCT_FUNCTION, NULL_TREE, remap_decl(), and TREE_CODE.
Referenced by expand_assign_tm(), gimple_build_omp_task(), and gimple_omp_task_set_copy_fn().
|
extern |
Determine if the function can be copied. If so return NULL. If not return a string describng the reason for failure.
References function::cannot_be_copied_reason, function::cannot_be_copied_set, G_, function::has_forced_label_in_static, and function::has_nonlocal_label.
Referenced by expand_target_clones(), inline_forbidden_p(), and tree_versionable_function_p().
|
extern |
Copies everything in SEQ and replaces variables and labels local to current_function_decl.
References CB_CGE_DUPLICATE, cfun, copy_decl_no_change(), current_function_decl, gimple_seq_copy(), mark_local_labels_stmt(), NULL, replace_locals_op(), replace_locals_stmt(), visited, and walk_gimple_seq().
Referenced by lower_omp_for_scan(), lower_omp_scan(), lower_transaction(), lower_try_finally_dup_block(), optimize_double_finally(), scan_omp_simd(), and scan_omp_simd_scan().
Called from copy_body_id via walk_tree. DATA is really a `copy_body_data *'.
References auto_var_in_fn_p(), build1(), build_empty_stmt(), CONSTANT_CLASS_P, copy_bind_expr(), copy_node(), copy_statement_list(), copy_tree_body_r(), copy_tree_r(), copy_warning(), DECL_CONTEXT, decl_function_context(), EXPR_LOCATION, EXPR_P, fold_build2, fold_convert, fold_indirect_ref_1(), gcc_assert, gimple_fold_indirect_ref(), i, INDIRECT_REF_P, is_gimple_min_invariant(), is_parm(), MR_DEPENDENCE_BASE, MR_DEPENDENCE_CLIQUE, NULL, NULL_TREE, OMP_CLAUSE_AFFINITY, OMP_CLAUSE_CODE, OMP_CLAUSE_DECL, OMP_CLAUSE_DEPEND, recompute_tree_invariant_for_addr_expr(), REF_REVERSE_STORAGE_ORDER, remap_block(), remap_decl(), remap_dependence_clique(), remap_save_expr(), remap_ssa_name(), remap_type(), STRIP_TYPE_NOPS, wi::to_wide(), TREE_BLOCK, TREE_CODE, TREE_CONSTANT, TREE_OPERAND, TREE_PURPOSE, TREE_READONLY, TREE_SET_BLOCK, TREE_SIDE_EFFECTS, TREE_THIS_NOTRAP, TREE_THIS_VOLATILE, TREE_TYPE, TREE_VALUE, TREE_VEC_ELT, TYPE_P, unshare_expr(), walk_tree, and wide_int_to_tree().
Referenced by add_local_variables(), copy_phis_for_bb(), copy_tree_body(), copy_tree_body_r(), fixup_child_record_type(), fixup_remapped_decl(), gimplify_omp_loop(), remap_decl(), remap_decls(), remap_type_1(), remap_vla_decls(), task_copyfn_remap_type(), and update_clone_info().
Passed to walk_tree. Copies the node pointed to, if appropriate.
References BIND_EXPR_BLOCK, CODE_CONTAINS_STRUCT, CONSTRUCTOR_ELTS, copy_node(), copy_statement_list(), IS_EXPR_CODE_CLASS, NULL_TREE, tcc_constant, tcc_declaration, tcc_type, TREE_CHAIN, TREE_CODE, TREE_CODE_CLASS, and vec_safe_copy().
Referenced by copy_bind_expr(), copy_self_referential_tree_r(), copy_tree_body_r(), mostly_copy_tree_r(), and remap_gimple_op_r().
References debug_find_tree_1(), and walk_tree_without_duplicates.
int estimate_num_insns | ( | gimple * | stmt, |
eni_weights * | weights ) |
Estimate number of instructions that will be created by expanding STMT. WEIGHTS contains weights attributed to various constructs.
References as_a(), asm_str_count(), BUILT_IN_NORMAL, eni_weights::call_cost, count, dconst2, DECL_FUNCTION_CODE(), symtab_node::definition, estimate_move_cost(), estimate_num_insns_seq(), estimate_operator_cost(), floor_log2(), fndecl_built_in_p(), gcc_unreachable, cgraph_node::get(), get_gimple_rhs_class(), gimple_asm_inline_p(), gimple_asm_string(), gimple_assign_lhs(), gimple_assign_load_p(), gimple_assign_rhs1(), gimple_assign_rhs2(), gimple_assign_rhs_code(), GIMPLE_BINARY_RHS, gimple_bind_body(), gimple_call_arg(), gimple_call_builtin_p(), gimple_call_fndecl(), gimple_call_internal_p(), gimple_call_lhs(), gimple_call_num_args(), gimple_catch_handler(), gimple_clobber_p(), gimple_cond_code(), gimple_eh_filter_failure(), gimple_omp_body(), gimple_omp_for_pre_body(), gimple_op(), gimple_store_p(), gimple_switch_num_labels(), gimple_transaction_body(), gimple_try_cleanup(), gimple_try_eval(), i, eni_weights::indirect_call_cost, is_inexpensive_builtin(), is_simple_builtin(), MAX, MIN, NULL, eni_weights::omp_cost, real_equal(), eni_weights::return_cost, walk_stmt_info::stmt, eni_weights::target_builtin_call_cost, eni_weights::time_based, eni_weights::tm_cost, TREE_CODE, TREE_REAL_CST, and TREE_TYPE.
Referenced by analyze_bb(), analyze_function_body(), back_threader_profitability::back_threader_profitability(), compute_added_num_insns(), early_inliner(), estimate_num_insns_fn(), estimate_num_insns_seq(), execute_split_functions(), gimple_account_profile_record(), init_loop_unswitch_info(), ipa_profile_generate_summary(), back_threader_profitability::possibly_profitable_path_p(), record_temporary_equivalences(), reorder_operands(), should_duplicate_loop_header_p(), tree_estimate_loop_size(), tree_num_loop_insns(), and value_replacement().
int estimate_num_insns_fn | ( | tree | fndecl, |
eni_weights * | weights ) |
Estimate number of instructions that will be created by expanding function FNDECL. WEIGHTS contains weights attributed to various constructs.
References function::cfg, DECL_STRUCT_FUNCTION, estimate_num_insns(), FOR_EACH_BB_FN, gcc_assert, gsi_end_p(), gsi_next(), gsi_start_bb(), and gsi_stmt().
int estimate_num_insns_seq | ( | gimple_seq | stmts, |
eni_weights * | weights ) |
Estimate number of instructions that will be created by expanding the statements in the statement sequence STMTS. WEIGHTS contains weights attributed to various constructs.
References estimate_num_insns(), walk_stmt_info::gsi, gsi_end_p(), gsi_next(), gsi_start(), and gsi_stmt().
Referenced by compute_added_num_insns(), decide_copy_try_finally(), estimate_num_insns(), and value_replacement().
Deal with mismatched formal/actual parameters, in a rather brute-force way if need be (which should only be necessary for invalid programs). Attempt to convert VAL to TYPE and return the result if it is possible, just return a zero constant of the given type if it fails.
References build_zero_cst(), error_mark_node, fold_build1, fold_convert, fold_convertible_p(), is_gimple_reg_type(), TREE_CODE, TREE_TYPE, and TYPE_SIZE.
Referenced by initialize_inlined_parameters(), ipa_param_adjustments::modify_call(), and setup_one_parameter().
void init_inline_once | ( | void | ) |
Function prototypes.
Initializes weights used by estimate_num_insns.
References eni_weights::call_cost, eni_weights::div_mod_cost, eni_size_weights, eni_time_weights, eni_weights::indirect_call_cost, eni_weights::omp_cost, eni_weights::return_cost, eni_weights::target_builtin_call_cost, eni_weights::time_based, and eni_weights::tm_cost.
Referenced by backend_init().
|
extern |
Insert a tree->tree mapping for ID. Despite the name suggests that the trees should be variables, it is used for more than that.
Referenced by add_taskreg_looptemp_clauses(), ipa_param_body_adjustments::common_initialization(), declare_return_variable(), install_var_local(), lower_omp_for(), ipa_param_body_adjustments::mark_dead_statements(), mark_local_labels_stmt(), omp_copy_decl(), remap_block(), remap_blocks_to_null(), remap_decl(), remap_ssa_name(), remap_type(), remap_type_1(), scan_omp_1_stmt(), scan_omp_parallel(), scan_sharing_clauses(), setup_one_parameter(), and tree_function_versioning().
EXP is CALL_EXPR present in a GENERIC expression tree. Try to integrate the callee and return the inlined body on success.
References CB_CGE_DUPLICATE, copy_decl_no_change(), copy_tree_body(), current_function_decl, DECL_ARGUMENTS, DECL_CHAIN, DECL_SAVED_TREE, DECL_STRUCT_FUNCTION, exp(), first_call_expr_arg(), get_callee_fndecl(), NULL_TREE, hash_map< KeyId, Value, Traits >::put(), TREE_CODE, TREE_OPERAND, and TREE_READONLY.
Referenced by substitute_in_expr().
unsigned int optimize_inline_calls | ( | tree | fn | ) |
Expand calls to inline functions in the body of FN.
References BASIC_BLOCK_FOR_FN, CB_CGE_DUPLICATE, CDI_DOMINATORS, CDI_POST_DOMINATORS, cfun, copy_decl_maybe_to_var(), current_function_decl, delete_unreachable_blocks_update_callgraph(), EXECUTE_IF_SET_IN_BITMAP, fold_marked_statements(), FOR_EACH_BB_FN, free_dominance_info(), gcc_assert, cgraph_node::get(), gimple_expand_calls_inline(), gimple_in_ssa_p(), gimple_purge_dead_abnormal_call_edges(), gimple_purge_dead_eh_edges(), gimple_register_cfg_hooks(), i, cgraph_edge::inline_failed, last, n_basic_blocks_for_fn, cgraph_edge::next_callee, NULL, number_blocks(), pop_gimplify_context(), push_gimplify_context(), to_purge, TODO_cleanup_cfg, TODO_remove_unused_locals, TODO_update_address_taken, TODO_update_ssa, and update_max_bb_count().
Referenced by autofdo::afdo_vpt_for_early_inline(), early_inliner(), and inline_transform().
|
extern |
Remap DECL during the copying of the BLOCK tree for the function.
References build_variant_type_copy(), copy_tree_body_r(), DECL_CONTEXT, DECL_FIELD_OFFSET, DECL_ORIGINAL_TYPE, DECL_P, DECL_QUALIFIER, DECL_SIZE, DECL_SIZE_UNIT, insert_decl_map(), NULL, processing_debug_stmt, remap_type(), TREE_CODE, TREE_TYPE, TYPE_NAME, TYPE_STUB_DECL, unshare_expr(), VAR_P, and walk_tree.
Referenced by add_local_variables(), adjust_assumption_stmt_op(), ipa_param_body_adjustments::carry_over_param(), copy_arguments_nochange(), copy_fn(), copy_loops(), copy_static_chain(), copy_tree_body_r(), finalize_nesting_tree_1(), fixup_remapped_decl(), remap_decl_1(), remap_decls(), remap_gimple_op_r(), remap_gimple_stmt(), remap_ssa_name(), remap_type_1(), remap_type_3(), remap_vla_decls(), replace_locals_stmt(), scan_omp_1_op(), and tree_function_versioning().
|
extern |
References insert_decl_map(), NULL, remap_type_1(), remap_type_2(), type(), and variably_modified_type_p().
Referenced by copy_tree_body_r(), finalize_nesting_tree_1(), fixup_child_record_type(), fixup_remapped_decl(), initialize_inlined_parameters(), lower_assumption(), lower_omp_task_reductions(), nesting_copy_decl(), remap_decl(), remap_gimple_op_r(), remap_ssa_name(), remap_type_1(), remap_vla_decls(), scan_omp_1_op(), scan_sharing_clauses(), and task_copyfn_remap_type().
Returns nonzero if FN is a function that does not have any fundamental inline blocking properties.
References DECL_ATTRIBUTES, DECL_DECLARED_INLINE_P, DECL_IN_SYSTEM_HEADER, DECL_NO_INLINE_WARNING_P, DECL_UNINLINABLE, error(), function_attribute_inlinable_p(), inline_forbidden_p(), inline_forbidden_reason, lookup_attribute(), NULL, opt_for_fn, and warning().
Referenced by compute_fn_summary().
Return true if the function is allowed to be versioned. This is a guard for the versioning functionality.
References copy_forbidden(), DECL_ATTRIBUTES, DECL_STRUCT_FUNCTION, lookup_attribute(), and NULL.
Referenced by can_strub_internally_p(), cgraph_node::create_version_clone_with_body(), execute_split_functions(), expand_target_clones(), ipa_fn_summary_generate(), and ipa_tm_execute().
|
extern |
Weights that estimate_num_insns uses for heuristics in inlining.
|
extern |
Weights that estimate_num_insns uses to estimate the size of the produced code.
Tree inlining. Copyright (C) 2001-2024 Free Software Foundation, Inc. Contributed by Alexandre Oliva <aoliva@redhat.com> 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/>.
I'm not real happy about this, but we need to handle gimple and non-gimple trees.
Inlining, Cloning, Versioning, Parallelization Inlining: a function body is duplicated, but the PARM_DECLs are remapped into VAR_DECLs, and non-void RETURN_EXPRs become MODIFY_EXPRs that store to a dedicated returned-value variable. The duplicated eh_region info of the copy will later be appended to the info for the caller; the eh_region info in copied throwing statements and RESX statements are adjusted accordingly. Cloning: (only in C++) We have one body for a con/de/structor, and multiple function decls, each with a unique parameter list. Duplicate the body, using the given splay tree; some parameters will become constants (like 0 or 1). Versioning: a function body is duplicated and the result is a new function rather than into blocks of an existing function as with inlining. Some parameters will become constants. Parallelization: a region of a function is duplicated resulting in a new function. Variables may be replaced with complex expressions to enable shared variable semantics. All of these will simultaneously lookup any callgraph edges. If we're going to inline the duplicated function body, and the given function has some cloned callgraph nodes (one for each place this function will be inlined) those callgraph edges will be duplicated. If we're cloning the body, those callgraph edges will be updated to point into the new body. (Note that the original callgraph node and edge list will not be altered.) See the CALL_EXPR handling case in copy_tree_body_r ().
To Do: o In order to make inlining-on-trees work, we pessimized function-local static constants. In particular, they are now always output, even when not addressed. Fix this by treating function-local static constants just like global static constants; the back-end already knows not to output them if they are not needed. o Provide heuristics to clamp inlining of recursive template calls?
Weights that estimate_num_insns uses to estimate the size of the produced code.
Referenced by analyze_bb(), analyze_function_body(), back_threader_profitability::back_threader_profitability(), can_unroll_loop_p(), compute_added_num_insns(), compute_fn_summary(), consider_split(), decide_copy_try_finally(), ipa_call_summary_t::duplicate(), early_inliner(), estimate_edge_devirt_benefit(), execute_split_functions(), gimple_account_profile_record(), init_inline_once(), init_loop_unswitch_info(), ipa_make_edge_direct_to_target(), ipa_profile_generate_summary(), loop_prefetch_arrays(), back_threader_profitability::possibly_profitable_path_p(), record_temporary_equivalences(), reorder_operands(), should_duplicate_loop_header_p(), and tree_estimate_loop_size().
|
extern |
Weights that estimate_num_insns uses to estimate the time necessary to execute the produced code.
Referenced by analyze_function_body(), compute_fn_summary(), ipa_call_summary_t::duplicate(), early_inliner(), estimate_edge_devirt_benefit(), execute_split_functions(), gimple_account_profile_record(), init_inline_once(), ipa_make_edge_direct_to_target(), ipa_profile_generate_summary(), loop_prefetch_arrays(), and value_replacement().