GCC Middle and Back End API Reference
tree-inline.h File Reference
This graph shows which files directly or indirectly include this file:

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 }
 

Functions

void init_inline_once (void)
 
tree copy_tree_body_r (tree *, int *, void *)
 
void insert_decl_map (copy_body_data *, tree, tree)
 
unsigned int optimize_inline_calls (tree)
 
tree maybe_inline_call_in_expr (tree)
 
bool tree_inlinable_function_p (tree)
 
tree copy_tree_r (tree *, int *, void *)
 
tree copy_decl_no_change (tree decl, copy_body_data *id)
 
int estimate_move_cost (tree type, bool)
 
int estimate_num_insns (gimple *, eni_weights *)
 
int estimate_num_insns_fn (tree, eni_weights *)
 
int estimate_num_insns_seq (gimple_seq, eni_weights *)
 
bool tree_versionable_function_p (tree)
 
tree remap_decl (tree decl, copy_body_data *id)
 
tree remap_type (tree type, copy_body_data *id)
 
gimple_seq copy_gimple_seq_and_replace_locals (gimple_seq seq)
 
bool debug_find_tree (tree, tree)
 
tree copy_fn (tree, tree &, tree &)
 
const charcopy_forbidden (struct function *fun)
 
tree copy_decl_for_dup_finish (copy_body_data *id, tree decl, tree copy)
 
tree copy_decl_to_var (tree, copy_body_data *)
 
tree force_value_to_type (tree type, tree value)
 
tree build_duplicate_type (tree)
 

Variables

eni_weights eni_inlining_weights
 
eni_weights eni_size_weights
 
eni_weights eni_time_weights
 

Typedef Documentation

◆ dependence_hash

Enumeration Type Documentation

◆ copy_body_cge_which

Indicate the desired behavior wrt call graph edges.  We can either
duplicate the edge (inlining, cloning), move the edge (versioning,
parallelization), or move the edges of the clones (saving).   
Enumerator
CB_CGE_DUPLICATE 
CB_CGE_MOVE 
CB_CGE_MOVE_CLONES 

Function Documentation

◆ build_duplicate_type()

tree build_duplicate_type ( tree type)
extern
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, ggc_alloc(), NULL, remap_type_1(), type(), and TYPE_CANONICAL.

◆ copy_decl_for_dup_finish()

tree copy_decl_for_dup_finish ( copy_body_data * id,
tree decl,
tree copy )
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().

◆ copy_decl_no_change()

◆ copy_decl_to_var()

tree copy_decl_to_var ( tree decl,
copy_body_data * id )
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, ggc_alloc(), 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().

◆ copy_fn()

tree copy_fn ( tree fn,
tree & parms,
tree & result )
extern
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, ggc_alloc(), NULL_TREE, remap_decl(), and TREE_CODE.

Referenced by expand_assign_tm(), gimple_build_omp_task(), and gimple_omp_task_set_copy_fn().

◆ copy_forbidden()

const char * copy_forbidden ( struct function * fun)
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_, ggc_alloc(), function::has_forced_label_in_static, and function::has_nonlocal_label.

Referenced by expand_target_clones(), inline_forbidden_p(), and tree_versionable_function_p().

◆ copy_gimple_seq_and_replace_locals()

◆ copy_tree_body_r()

◆ copy_tree_r()

◆ debug_find_tree()

bool debug_find_tree ( tree top,
tree search )
extern

◆ estimate_move_cost()

int estimate_move_cost ( tree type,
bool  )

◆ estimate_num_insns()

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 asm_str_count(), BUILT_IN_NORMAL, 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(), ggc_alloc(), 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, is_inexpensive_builtin(), is_simple_builtin(), MAX, MIN, NULL, real_equal(), walk_stmt_info::stmt, 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().

◆ estimate_num_insns_fn()

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 DECL_STRUCT_FUNCTION, estimate_num_insns(), FOR_EACH_BB_FN, gcc_assert, ggc_alloc(), gsi_end_p(), gsi_next(), gsi_start_bb(), and gsi_stmt().

◆ estimate_num_insns_seq()

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(), ggc_alloc(), 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().

◆ force_value_to_type()

tree force_value_to_type ( tree type,
tree value )
extern
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(), ggc_alloc(), 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().

◆ init_inline_once()

◆ insert_decl_map()

◆ maybe_inline_call_in_expr()

tree maybe_inline_call_in_expr ( tree exp)

◆ optimize_inline_calls()

◆ remap_decl()

◆ remap_type()

◆ tree_inlinable_function_p()

bool tree_inlinable_function_p ( tree fn)

◆ tree_versionable_function_p()

bool tree_versionable_function_p ( tree fndecl)
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().

Variable Documentation

◆ eni_inlining_weights

eni_weights eni_inlining_weights
extern
Weights that estimate_num_insns uses for heuristics in inlining.   

◆ eni_size_weights

eni_weights eni_size_weights
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().

◆ eni_time_weights