GCC Middle and Back End API Reference
tree-inline.c File Reference

Functions

static tree declare_return_variable (copy_body_data *, tree, tree, basic_block)
static void remap_block (tree *, copy_body_data *)
static void copy_bind_expr (tree *, int *, copy_body_data *)
static void declare_inline_vars (tree, tree)
static void remap_save_expr (tree *, void *, int *)
static void prepend_lexical_block (tree current_block, tree new_block)
static tree copy_decl_to_var (tree, copy_body_data *)
static tree copy_result_decl_to_var (tree, copy_body_data *)
static tree copy_decl_maybe_to_var (tree, copy_body_data *)
static gimple remap_gimple_stmt (gimple, copy_body_data *)
static bool delete_unreachable_blocks_update_callgraph (copy_body_data *id)
void insert_decl_map ()
static void insert_debug_decl_map ()
static tree remap_ssa_name ()
tree remap_decl ()
static tree remap_type_1 ()
tree remap_type ()
static bool can_be_nonlocal ()
static tree remap_decls (tree decls, vec< tree, va_gc > **nonlocalized_list, copy_body_data *id)
static void remap_block ()
static tree remap_blocks ()
static void remap_blocks_to_null ()
static void copy_statement_list ()
static void copy_bind_expr ()
static gimple_seq remap_gimple_seq ()
static gimple copy_gimple_bind ()
static bool is_parm ()
static tree remap_gimple_op_r ()
tree copy_tree_body_r ()
static int remap_eh_region_nr ()
static tree remap_eh_region_tree_nr ()
static gimple remap_gimple_stmt ()
static basic_block copy_bb (copy_body_data *id, basic_block bb, int frequency_scale, gcov_type count_scale)
static void update_ssa_across_abnormal_edges (basic_block bb, basic_block ret_bb, bool can_throw, bool nonlocal_goto)
static bool copy_edges_for_bb (basic_block bb, gcov_type count_scale, basic_block ret_bb, bool can_make_abnormal_goto)
static void copy_phis_for_bb ()
static tree remap_decl_1 ()
static void initialize_cfun ()
static void maybe_move_debug_stmts_to_successors ()
static void copy_loops (copy_body_data *id, struct loop *dest_parent, struct loop *src_parent)
void redirect_all_calls ()
static tree copy_cfg_body (copy_body_data *id, gcov_type count, int frequency_scale, basic_block entry_block_map, basic_block exit_block_map, basic_block new_entry)
static void copy_debug_stmt ()
static void copy_debug_stmts ()
static tree copy_tree_body ()
static tree copy_body (copy_body_data *id, gcov_type count, int frequency_scale, basic_block entry_block_map, basic_block exit_block_map, basic_block new_entry)
static bool self_inlining_addr_expr ()
static gimple insert_init_debug_bind (copy_body_data *id, basic_block bb, tree var, tree value, gimple base_stmt)
static void insert_init_stmt ()
static gimple setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn, basic_block bb, tree *vars)
static void initialize_inlined_parameters (copy_body_data *id, gimple stmt, tree fn, basic_block bb)
static tree has_label_address_in_static_1 ()
static const char * copy_forbidden ()
static tree inline_forbidden_p_stmt (gimple_stmt_iterator *gsi, bool *handled_ops_p, struct walk_stmt_info *wip)
static bool inline_forbidden_p ()
static bool function_attribute_inlinable_p ()
bool tree_inlinable_function_p ()
int estimate_move_cost ()
static int estimate_operator_cost (enum tree_code code, eni_weights *weights, tree op1, tree op2)
static int estimate_num_insns_seq (gimple_seq stmts, eni_weights *weights)
int estimate_num_insns ()
int estimate_num_insns_fn ()
void init_inline_once ()
int count_insns_seq ()
static void prepend_lexical_block ()
static void add_local_variables (struct function *callee, struct function *caller, copy_body_data *id)
static bool expand_call_inline ()
static bool gimple_expand_calls_inline ()
static void fold_marked_statements ()
static bool has_abnormal_outgoing_edge_p ()
unsigned int optimize_inline_calls ()
tree copy_tree_r ()
static void remap_save_expr ()
static tree mark_local_labels_stmt (gimple_stmt_iterator *gsip, bool *handled_ops_p, struct walk_stmt_info *wi)
static tree replace_locals_op ()
static tree replace_locals_stmt (gimple_stmt_iterator *gsip, bool *handled_ops_p, struct walk_stmt_info *wi)
gimple_seq copy_gimple_seq_and_replace_locals ()
static tree debug_find_tree_1 ()
DEBUG_FUNCTION bool debug_find_tree ()
static void declare_inline_vars ()
static tree copy_decl_for_dup_finish ()
static tree copy_decl_to_var ()
static tree copy_result_decl_to_var ()
tree copy_decl_no_change ()
static tree copy_decl_maybe_to_var ()
static tree copy_arguments_for_versioning (tree orig_parm, copy_body_data *id, bitmap args_to_skip, tree *vars)
static tree copy_static_chain ()
bool tree_versionable_function_p ()
static bool delete_unreachable_blocks_update_callgraph ()
static void update_clone_info ()
void tree_function_versioning (tree old_decl, tree new_decl, vec< ipa_replace_map_p, va_gc > *tree_map, bool update_clones, bitmap args_to_skip, bool skip_return, bitmap blocks_to_copy, basic_block new_entry)
tree maybe_inline_call_in_expr ()
tree build_duplicate_type ()

Variables

eni_weights eni_size_weights
eni_weights eni_time_weights
static int processing_debug_stmt = 0
static const char * inline_forbidden_reason

Function Documentation

static void add_local_variables ( struct function callee,
struct function caller,
copy_body_data id 
)
inlinestatic
   Add local variables from CALLEE to CALLER.  
           Remap debug-expressions.  
tree build_duplicate_type ( )
   Duplicate a type, fields and all.  
static bool can_be_nonlocal ( )
static
   Decide if DECL can be put into BLOCK_NONLOCAL_VARs.  
     We can not duplicate function decls.  
     Local static vars must be non-local or we get multiple declaration
     problems.  
static tree copy_arguments_for_versioning ( tree  orig_parm,
copy_body_data id,
bitmap  args_to_skip,
tree vars 
)
static
   Return a copy of the function's argument tree.  
           Make an equivalent VAR_DECL.  If the argument was used
           as temporary variable later in function, the uses will be
           replaced by local variable.  
           Declare this new variable.  
static basic_block copy_bb ( copy_body_data id,
basic_block  bb,
int  frequency_scale,
gcov_type  count_scale 
)
static
   Copy basic block, scale profile accordingly.  Edges will be taken care of
   later  
     Search for previous copied basic block.  
     create_basic_block() will append every new block to
     basic_block_info automatically.  
     We are going to rebuild frequencies from scratch.  These values
     have just small importance to drive canonicalize_loop_headers.  
     We recompute frequencies after inlining, so this is quite safe.  
         With return slot optimization we can end up with
         non-gimple (foo *)&this->m, fix that here.  
         If copy_basic_block has been empty at the start of this iteration,
         call gsi_start_bb again to get at the newly added statements.  
         Process the new statement.  The call to gimple_regimplify_operands
         possibly turned the statement into multiple statements, we
         need to process all of them.  
                 __builtin_va_arg_pack () should be replaced by
                 all arguments corresponding to ... in the caller.  
                 Create the new array of arguments.  
                 Copy all the arguments before '...'  
                 Append the arguments passed in '...'  
                 Copy all GIMPLE_CALL flags, location and block, except
                 GF_CALL_VA_ARG_PACK.  
                 __builtin_va_arg_pack_len () should be replaced by
                 the number of anonymous arguments.  
             Statements produced by inlining can be unfolded, especially
             when we constant propagated some operands.  We can't fold
             them right now for two reasons:
             1) folding require SSA_NAME_DEF_STMTs to be correct
             2) we can't change function calls to builtins.
             So we just mark statement for later folding.  We mark
             all new statements, instead just statements that has changed
             by some nontrivial substitution so even statements made
             foldable indirectly are updated.  If this turns out to be
             expensive, copy_body can be told to watch for nontrivial
             changes.  
             We're duplicating a CALL_EXPR.  Find any corresponding
             callgraph edges and update or duplicate them.  
                         We could also just rescale the frequency, but
                         doing so would introduce roundoff errors and make
                         verifier unhappy.  
                         Speculative calls consist of two edges - direct and indirect.
                         Duplicate the whole thing and distribute frequencies accordingly.  
                 Constant propagation on argument done during inlining
                 may create new direct call.  Produce an edge for it.  
                     We have missing edge in the callgraph.  This can happen
                     when previous inlining turned an indirect call into a
                     direct call by constant propagating arguments or we are
                     producing dead clone (for further cloning).  In all
                     other cases we hit a bug (incorrect node sharing is the
                     most common reason for missing edges).  
static void copy_bind_expr ( tree ,
int *  ,
copy_body_data  
)
static
static void copy_bind_expr ( )
static
     Copy (and replace) the statement.  
       This will remap a lot of the same decls again, but this should be
       harmless.  
static tree copy_body ( copy_body_data id,
gcov_type  count,
int  frequency_scale,
basic_block  entry_block_map,
basic_block  exit_block_map,
basic_block  new_entry 
)
static
   Make a copy of the body of FN so that it can be inserted inline in
   another function.  
     If this body has a CFG, walk CFG and copy.  
static tree copy_cfg_body ( copy_body_data id,
gcov_type  count,
int  frequency_scale,
basic_block  entry_block_map,
basic_block  exit_block_map,
basic_block  new_entry 
)
static
   Make a copy of the body of FN so that it can be inserted inline in
   another function.  Walks FN via CFG, returns new fndecl.  
     Original cfun for the callee, doesn't change.  
     Register specific tree functions.  
     If we are inlining just region of the function, make sure to connect new entry
     to ENTRY_BLOCK_PTR.  Since new entry can be part of loop, we must compute
     frequency and probability of ENTRY_BLOCK_PTR based on the frequencies and
     probabilities of edges incoming from nonduplicated region.  
     Must have a CFG here at this point.  
     Duplicate any exception-handling regions.  
     Use aux pointers to map the original blocks to copy.  
     Now that we've duplicated the blocks, duplicate their edges.  
     Duplicate the loop tree, if available and wanted.  
         Defer to cfgcleanup to update loop-father fields of basic-blocks.  
     If the loop tree in the source function needed fixup, mark the
     destination loop tree for fixup, too.  
           Update call edge destinations.  This can not be done before loop
           info is updated, because we may split basic blocks.  
     Zero out AUX fields of newly created block during EH edge
     insertion. 
         Update call edge destinations.  This can not be done before loop
         info is updated, because we may split basic blocks.  
static void copy_debug_stmt ( )
static
   Copy the debug STMT using ID.  We deal with these statements in a
   special way: if any variable in their VALUE expression wasn't
   remapped yet, we won't remap it, because that would get decl uids
   out of sync, causing codegen differences between -g and -g0.  If
   this arises, we drop the VALUE expression altogether.  
     Remap all the operands in COPY.  
       T is a non-localized variable.  
         Punt if any decl couldn't be remapped.  
         When inlining and source bind refers to one of the optimized
         away parameters, change the source bind into normal debug bind
         referring to the corresponding DEBUG_EXPR_DECL that should have
         been bound before the call stmt.  
static void copy_debug_stmts ( )
static
   Process deferred debug stmts.  In order to give values better odds
   of being successfully remapped, we delay the processing of debug
   stmts until all other stmts that might require remapping are
   processed.  

References is_gimple_min_invariant(), and useless_type_conversion_p().

static tree copy_decl_for_dup_finish ( )
static
   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.  
     Don't generate debug information for the copy if we wouldn't have
     generated it for the copy either.  
     Set the DECL_ABSTRACT_ORIGIN so the debugging routines know what
     declaration inspired this copy.  
     The new variable/label has no RTL, yet.  
     These args would always appear unused, if not for this.  
     Set the context for the new declaration.  
       Globals stay global.  
       Things that weren't in the scope of the function we're inlining
       from aren't in the scope we're inlining to, either.  
       Function-scoped static variables should stay in the original
       function.  
       Ordinary automatic local variables are now in the scope of the
       new function.  
static tree copy_decl_maybe_to_var ( tree  ,
copy_body_data  
)
static
static tree copy_decl_maybe_to_var ( )
static
tree copy_decl_no_change ( )
     The COPY is not abstract; it will be generated in DST_FN.  
     TREE_ADDRESSABLE isn't used to indicate that a label's address has
     been taken; it's for internal bookkeeping in expand_goto_internal.  

References cfun, function::returns_pcc_struct, and function::returns_struct.

Referenced by delete_unreachable_blocks_update_callgraph().

static tree copy_decl_to_var ( tree  ,
copy_body_data  
)
static
static tree copy_decl_to_var ( )
static
static bool copy_edges_for_bb ( basic_block  bb,
gcov_type  count_scale,
basic_block  ret_bb,
bool  can_make_abnormal_goto 
)
static
   Copy edges from BB into its copy constructed earlier, scale profile
   accordingly.  Edges will be taken care of later.  Assume aux
   pointers to point to the copies of each BB.  Return true if any
   debug stmts are left after a statement that must end the basic block.  
     Use the indices from the original blocks to create edges for the
     new ones.  
           Return edges do get a FALLTHRU flag when the get inlined.  
         Do this before the possible split_block.  
         If this tree could throw an exception, there are two
         cases where we need to add abnormal edge(s): the
         tree wasn't in a region and there is a "current
         region" in the caller; or the original tree had
         EH edges.  In both cases split the block after the tree,
         and add abnormal edge(s) as needed; we need both
         those from the callee and the caller.
         We check whether the copy can throw, because the const
         propagation can change an INDIRECT_REF which throws
         into a COMPONENT_REF which doesn't.  If the copy
         can throw, the original could also throw.  
               Note that bb's predecessor edges aren't necessarily
               right at this point; split_block doesn't care.  
         If the call we inline cannot make abnormal goto do not add
         additional abnormal edges but only retain those already present
         in the original function body.  

References force_gimple_operand(), gsi_insert_seq_on_edge(), and inserted.

static const char* copy_forbidden ( )
static
   Determine if the function can be copied.  If so return NULL.  If
   not return a string describng the reason for failure.  
     Only examine the function once.  
     We cannot copy a function that receives a non-local goto
     because we cannot remap the destination label used in the
     function that is performing the non-local goto.  
     ??? Actually, this should be possible, if we work at it.
     No doubt there's just a handful of places that simply
     assume it doesn't happen and don't substitute properly.  
static gimple copy_gimple_bind ( )
static
   Copy a GIMPLE_BIND statement STMT, remapping all the symbols in its
   block using the mapping information in ID.  
     Copy the statement.  Note that we purposely don't use copy_stmt
     here because we need to remap statements as we copy.  
     This will remap a lot of the same decls again, but this should be
     harmless.  

References remap_ssa_name().

gimple_seq copy_gimple_seq_and_replace_locals ( )
   Copies everything in SEQ and replaces variables and labels local to
   current_function_decl.  
     There's nothing to do for NULL_TREE.  
     Set up ID.  
     Walk the tree once to find local labels.  
     Walk the copy, remapping decls.  
     Clean up.  

References cgraph_node::clone_of, copy_body_data::dst_node, and cgraph_node::next_sibling_clone.

static void copy_loops ( copy_body_data id,
struct loop dest_parent,
struct loop src_parent 
)
static
   Make a copy of the sub-loops of SRC_PARENT and place them
   as siblings of DEST_PARENT.  
             Assign the new loop its header and latch and associate
             those with the new loop.  
             Copy loop meta-data.  
             Finally place it into the loop array and the loop tree.  
             Recurse.  

References get_loop(), basic_block_def::loop_father, LOOPS_NEED_FIXUP, and loops_state_set().

static void copy_phis_for_bb ( )
static
   Copy the PHIs.  All blocks and edges are copied, some blocks
   was possibly split and new outgoing EH edges inserted.
   BB points to the block of original function and AUX pointers links
   the original and newly copied blocks.  
                 When doing partial cloning, we allow PHIs on the entry block
                 as long as all the arguments are the same.  Find any input
                 edge to see argument to copy.  
                 With return slot optimization we can end up with
                 non-gimple (foo *)&this->m, fix that here.  
     Commit the delayed edge insertions.  
static tree copy_result_decl_to_var ( tree  ,
copy_body_data  
)
static
static tree copy_result_decl_to_var ( )
static
   Like copy_decl_to_var, but create a return slot object instead of a
   pointer variable for return by invisible reference.  

References ipa_replace_map::new_tree, ipa_replace_map::old_tree, and setup_one_parameter().

static void copy_statement_list ( )
static
           This copy is not redundant; tsi_link_after will smash this
           STATEMENT_LIST into the end of the one we're building, and we
           don't want to do that with the original.  
static tree copy_tree_body ( )
static
   Make a copy of the body of SRC_FN so that it can be inserted inline in
   another function.  

References insert_debug_decl_map(), insert_decl_map(), and insert_init_debug_bind().

Referenced by delete_unreachable_blocks_update_callgraph().

tree copy_tree_body_r ( )
   Called from copy_body_id via walk_tree.  DATA is really a
   `copy_body_data *'.  
     Begin by recognizing trees that we'll completely rewrite for the
     inlining context.  Our output for these trees is completely
     different from out input (e.g. RETURN_EXPR is deleted, and morphs
     into an edge).  Further down, we'll handle trees that get
     duplicated and/or tweaked.  
     When requested, RETURN_EXPRs should be transformed to just the
     contained MODIFY_EXPR.  The branch semantics of the return will
     be handled elsewhere by manipulating the CFG rather than a statement.  
         If we're returning something, just turn that into an
         assignment into the equivalent of the original RESULT_DECL.
         If the "assignment" is just the result decl, the result
         decl has already been set (e.g. a recent "foo (&result_decl,
         ...)"); just toss the entire RETURN_EXPR.  
             Replace the RETURN_EXPR with (a copy of) the
             MODIFY_EXPR hanging underneath.  
     Local variables and labels need to be replaced by equivalent
     variables.  We don't want to copy static variables; there's only
     one of those, no matter how many times we inline the containing
     function.  Similarly for globals from an outer function.  
         Remap the declaration.  
         Replace this variable with the copy.  
       These may need to be remapped for EH handling.  
     Types may need remapping as well.  
     If this is a constant, we have to copy the node iff the type will be
     remapped.  copy_tree_r will not copy a constant.  
     Otherwise, just copy the node.  Note that copy_tree_r already
     knows not to copy VAR_DECLs, etc., so this is safe.  
         Here we handle trees that are not completely rewritten.
         First we detect some inlining-induced bogosities for
         discarding.  
             Some assignments VAR = VAR; don't generate any rtl code
             and thus don't count as variable modification.  Avoid
             keeping bogosities like 0 = 0.  
             Get rid of *& from inline substitutions that can happen when a
             pointer argument is an ADDR_EXPR.  
                 If we happen to get an ADDR_EXPR in n->value, strip
                 it manually here as we'll eventually get ADDR_EXPRs
                 which lie about their types pointed to.  In this case
                 build_fold_indirect_ref wouldn't strip the INDIRECT_REF,
                 but we absolutely rely on that.  As fold_indirect_ref
                 does other useful transformations, try that first, though.  
                         ???  We should either assert here or build
                         a VIEW_CONVERT_EXPR instead of blindly leaking
                         incompatible types to our IL.  
                         We cannot propagate the TREE_THIS_NOTRAP flag if we
                         have remapped a parameter as the property might be
                         valid only for the parameter itself.  
             We need to re-canonicalize MEM_REFs from inline substitutions
             that can happen when a pointer argument is an ADDR_EXPR.
             Recurse here manually to allow that.  
             We cannot propagate the TREE_THIS_NOTRAP flag if we have
             remapped a parameter as the property might be valid only
             for the parameter itself.  
         Here is the "usual case".  Copy this tree node, and then
         tweak some special cases.  
         If EXPR has block defined, map it to newly constructed block.
         When inlining we want EXPRs without block appear in the block
         of function call if we are not remapping a type.  
         The copied TARGET_EXPR has never been expanded, even if the
         original node was expanded already.  
         Variable substitution need not be simple.  In particular, the
         INDIRECT_REF substitution above.  Make sure that TREE_CONSTANT
         and friends are up-to-date.  
             Handle the case where we substituted an INDIRECT_REF
             into the operand of the ADDR_EXPR.  
             If this used to be invariant, but is not any longer,
             then regimplification is probably needed.  
     Keep iterating.  

References build_int_cst_wide(), copy_node(), and remap_type().

Referenced by finalize_task_copyfn(), and remap_decl().

tree copy_tree_r ( )
   Passed to walk_tree.  Copies the node pointed to, if appropriate.  
     We make copies of most nodes.  
         Because the chain gets clobbered when we make a copy, we save it
         here.  
         Copy the node.  
         Now, restore the chain, if appropriate.  That will cause
         walk_tree to walk into the chain as well.  
         For now, we don't update BLOCKs when we make copies.  So, we
         have to nullify all BIND_EXPRs.  
         CONSTRUCTOR nodes need special handling because
         we need to duplicate the vector of elements.  
       We used to just abort on STATEMENT_LIST, but we can run into them
       with statement-expressions (c++/40975).  
int count_insns_seq ( )
   Estimate the number of instructions in a gimple_seq. 
DEBUG_FUNCTION bool debug_find_tree ( )
static tree debug_find_tree_1 ( )
static
   Allow someone to determine if SEARCH is a child of TOP from gdb.  
static void declare_inline_vars ( tree  ,
tree   
)
static
static void declare_inline_vars ( )
static
   Declare the variables created by the inliner.  Add all the variables in
   VARS to BIND_EXPR.  
static tree declare_return_variable ( copy_body_data id,
tree  return_slot,
tree  modify_dest,
basic_block  entry_bb 
)
static
   Prototypes.  
   Declare a return variable to replace the RESULT_DECL for the
   function we are calling.  An appropriate DECL_STMT is returned.
   The USE_STMT is filled to contain a use of the declaration to
   indicate the return value of the function.

   RETURN_SLOT, if non-null is place where to store the result.  It
   is set only for CALL_EXPR_RETURN_SLOT_OPT.  MODIFY_DEST, if non-null,
   was the LHS of the MODIFY_EXPR to which this call is the RHS.

   The return value is a (possibly null) value that holds the result
   as seen by the caller.  
     Handle type-mismatches in the function declaration return type
     vs. the call expression.  
     We don't need to do anything for functions that don't return anything.  
     If there was a return slot, then the return value is the
     dereferenced address of that object.  
         The front end shouldn't have used both return_slot and
         a modify expression.  
             We are going to construct *&return_slot and we can't do that
             for variables believed to be not addressable.

             FIXME: This check possibly can match, because values returned
             via return slot optimization are not believed to have address
             taken by alias analysis.  
     All types requiring non-trivial constructors should have been handled.  
     Attempt to avoid creating a new temporary variable.  
         We can't use MODIFY_DEST if there's type promotion involved.  
         ??? If we're assigning to a variable sized type, then we must
         reuse the destination variable, because we've no good way to
         create variable sized temporaries at this point.  
         If the callee cannot possibly modify MODIFY_DEST, then we can
         reuse it as the result of the call directly.  Don't do this if
         it would promote MODIFY_DEST to addressable.  
             If the base isn't a decl, then it's a pointer, and we don't
             know where that's going to go.  
     Do not have the rest of GCC warn about this variable as it should
     not be visible to the user.  
     Build the use expr.  If the return type of the function was
     promoted, convert it back to the expected type.  
         If we can match up types by promotion/demotion do so.  
             ???  For valid programs we should not end up here.
             Still if we end up with truly mismatched types here, fall back
             to using a MEM_REF to not leak invalid GIMPLE to the following
             passes.  
             Prevent var from being written into SSA form.  
     Register the VAR_DECL as the equivalent for the RESULT_DECL; that
     way, when the RESULT_DECL is encountered, it will be
     automatically replaced by the VAR_DECL.  

     When returning by reference, ensure that RESULT_DECL remaps to
     gimple_val.  
         When RESULT_DECL is in SSA form, we need to remap and initialize
         it's default_def SSA_NAME.  
     Remember this so we can ignore it in remap_decls.  
static bool delete_unreachable_blocks_update_callgraph ( copy_body_data id)
static
static bool delete_unreachable_blocks_update_callgraph ( )
static
   Delete all unreachable basic blocks and update callgraph.
   Doing so is somewhat nontrivial because we need to update all clones and
   remove inline function that become unreachable.  
     Delete all unreachable basic blocks.  

References CB_CGE_DUPLICATE, copy_decl_no_change(), copy_tree_body(), current_function_decl, first_call_expr_arg(), get_callee_fndecl(), memset(), next_call_expr_arg(), pointer_map_create(), pointer_map_destroy(), and pointer_map_insert().

int estimate_move_cost ( )
   Estimate the cost of a memory move.  Use machine dependent
   word size and take possible memcpy call into account.  
       Cost of a memcpy call, 3 arguments and the call.  

References dconst2, estimate_operator_cost(), and gimple_call_arg().

Referenced by agg_jmp_p_vec_for_t_vec().

int estimate_num_insns ( )
   Estimate number of instructions that will be created by expanding STMT.
   WEIGHTS contains weights attributed to various constructs.  
         Try to estimate the cost of assignments.  We have three cases to
         deal with:
         1) Simple assignments to registers;
         2) Stores to things that must live in memory.  This includes
            "normal" stores to scalars, but also assignments of large
            structures, or constructors of big arrays;

         Let us look at the first two cases, assuming we have "a = b + C":
         <GIMPLE_ASSIGN <var_decl "a">
                <plus_expr <var_decl "b"> <constant C>>
         If "a" is a GIMPLE register, the assignment to it is free on almost
         any target, because "a" usually ends up in a real register.  Hence
         the only cost of this expression comes from the PLUS_EXPR, and we
         can ignore the GIMPLE_ASSIGN.
         If "a" is not a GIMPLE register, the assignment to "a" will most
         likely be a real store, so the cost of the GIMPLE_ASSIGN is the cost
         of moving something into "a", which we compute using the function
         estimate_move_cost.  
         Account for the cost of moving to / from memory.  
         Take into account cost of the switch + guess 2 conditional jumps for
         each case label.

         TODO: once the switch expansion logic is sufficiently separated, we can
         do better job on estimating cost of the switch.  
           Do not special case builtins where we see the body.
           This just confuse inliner.  
           For buitins that are likely expanded to nothing or
           inlined do not account operand costs.  
               We canonicalize x * x to pow (x, 2.0) with -ffast-math, so
               specialize the cheap expansion we do here.
               ???  This asks for a more general solution.  
           1000 means infinity. This avoids overflows later
           with very long asm statements.  
         This is either going to be an external function call with one
         argument, or two register copy statements plus a goto.  
         ??? This is going to turn into a switch statement.  Ideally
         we'd have a look at the eh region and estimate the number of
         edges involved.  
       OpenMP directives are generally very expensive.  
         ...except these, which are cheap.  

Referenced by count_insns(), and function_attribute_inlinable_p().

int estimate_num_insns_fn ( )
   Estimate number of instructions that will be created by expanding
   function FNDECL.  WEIGHTS contains weights attributed to various
   constructs.  

References gimple_build_predict(), gsi_insert_after(), gsi_last_bb(), GSI_NEW_STMT, and NOT_TAKEN.

static int estimate_num_insns_seq ( gimple_seq  stmts,
eni_weights weights 
)
static
   Estimate number of instructions that will be created by expanding
   the statements in the statement sequence STMTS.
   WEIGHTS contains weights attributed to various constructs.  
static int estimate_operator_cost ( enum tree_code  code,
eni_weights weights,
tree  op1,
tree  op2 
)
static
   Returns cost of operation CODE, according to WEIGHTS  
       These are "free" conversions, or their presumed cost
       is folded into other operations.  
       Assign cost of 1 to usual operations.
       ??? We may consider mapping RTL costs to this.  
       Few special cases of expensive operations.  This is useful
       to avoid inlining on functions having too many of these.  
         We expect a copy assignment with no operator.  

Referenced by estimate_move_cost().

static bool expand_call_inline ( )
static
   If STMT is a GIMPLE_CALL, replace it with its inline expansion.  
     Set input_location here so we get the right instantiation context
     if we call instantiate_decl from inlinable_function_p.  
     FIXME: instantiate_decl isn't called by inlinable_function_p.  
     From here on, we're only interested in CALL_EXPRs.  
     First, see if we can figure out what function is being called.
     If we cannot, then there is no hope of inlining the function.  
     If FN is a declaration of a function in a nested scope that was
     globally declared inline, we don't set its DECL_INITIAL.
     However, we can't blindly follow DECL_ABSTRACT_ORIGIN because the
     C++ front-end uses it for cdtors to refer to their internal
     declarations, that are not real functions.  Fortunately those
     don't have trees to be saved, so we can tell by checking their
     gimple_body.  
     Don't try to inline functions that are not well-suited to inlining.  
         If this call was originally indirect, we do not want to emit any
         inlining related warnings or sorry messages because there are no
         guarantees regarding those.  
             For extern inline functions that get redefined we always
             silently ignored always_inline flag. Better behaviour would
             be to be able to keep both bodies and use extern inline body
             for inlining, but we can't do that because frontends overwrite
             the body.  
             During early inline pass, report only when optimization is
             not turned on.  
             PR 20090218-1_0.c. Body can be provided by another module. 
                  Do not warn about not inlined recursive calls.  
                  Avoid warnings during early inline pass. 
     We will be inlining this callee.  
     Update the callers EH personality.  
     Split the block holding the GIMPLE_CALL.  
     split_block splits after the statement; work around this by
     moving the call into the second block manually.  Not pretty,
     but seems easier than doing the CFG manipulation by hand
     when the GIMPLE_CALL is in the last statement of BB.  
     If the GIMPLE_CALL was in the last statement of BB, it may have
     been the source of abnormal edges.  In this case, schedule
     the removal of dead abnormal edges.  
     Build a block containing code to initialize the arguments, the
     actual inline expansion of the body, and a label for the return
     statements within the function to jump to.  The type of the
     statement expression is the return type of the function call.
     ???  If the call does not have an associated block then we will
     remap all callee blocks to NULL, effectively dropping most of
     its debug information.  This should only happen for calls to
     artificial decls inserted by the compiler itself.  We need to
     either link the inlined blocks into the caller block tree or
     not refer to them in any way to not break GC for locations.  
     Local declarations will be replaced by their equivalents in this
     map.  
     Record the function we are about to inline.  
             Move vars for PARM_DECLs from DECL_INITIAL block to id->block,
             otherwise for DWARF DW_TAG_formal_parameter will not be children of
             DW_TAG_inlined_subroutine, but of a DW_TAG_lexical_block
             under it.  The parameters can be then evaluated in the debugger,
             but don't show in backtraces.  
     Return statements in the function body will be replaced by jumps
     to the RET_LABEL.  
     Find the LHS to which the result of this call is assigned.  
         The function which we are inlining might not return a value,
         in which case we should issue a warning that the function
         does not return a value.  In that case the optimizers will
         see that the variable to which the value is assigned was not
         initialized.  We do not want to issue a warning about that
         uninitialized variable.  
     If we are inlining a call to the C++ operator new, we don't want
     to use type based alias analysis on the return value.  Otherwise
     we may get confused if the compiler sees that the inlined new
     function returns a pointer which was just deleted.  See bug
     33407.  
     Declare the return variable for the function.  
     Add local vars in this inlined callee to caller.  
     This is it.  Duplicate the callee body.  Assume callee is
     pre-gimplified.  Note that we must not alter the caller
     function in any way before this point, as this CALL_EXPR may be
     a self-referential call; if we're calling ourselves, we need to
     duplicate our body before altering anything.  
     Reset the escaped solution.  
     Clean up.  
     Unlink the calls virtual operands before replacing it.  
     If the inlined function returns a result that we care about,
     substitute the GIMPLE_CALL with an assignment of the return
     variable to the LHS of the call.  That is, if STMT was
     'a = foo (...)', substitute the call with 'a = USE_RETVAR'.  
         Handle the case of inlining a function with no return
         statement, which causes the return value to become undefined.  
                 If the variable is used undefined, make this name
                 undefined via a move.  
                 Otherwise make this variable undefined.  
     If the value of the new expression is ignored, that's OK.  We
     don't warn about this for CALL_EXPRs, so we shouldn't warn about
     the equivalent inlined version either.  
     Output the inlining info for this abstract function, since it has been
     inlined.  If we don't do this now, we can lose the information about the
     variables in the function when the blocks get blown away as soon as we
     remove the cgraph node.  
     Update callgraph if needed.  
static void fold_marked_statements ( )
static
   Walk all basic blocks created after FIRST and try to fold every statement
   in the STATEMENTS pointer set.  
                     Folding builtins can create multiple instructions,
                     we need to look at all of them.  
                         If a builtin at the end of a bb folded into nothing,
                         the following loop won't work.  
                                 It is okay to check only for the very last
                                 of these statements.  If it is a throwing
                                 statement nothing will change.  If it isn't
                                 this can remove EH edges.  If that weren't
                                 correct then because some intermediate stmts
                                 throw, but not the last one.  That would mean
                                 we'd have to split the block, which we can't
                                 here and we'd loose anyway.  And as builtins
                                 probably never throw, this all
                                 is mood anyway.  
                     Re-read the statement from GSI as fold_stmt() may
                     have changed it.  

References pointer_map_contains().

static bool function_attribute_inlinable_p ( )
static
   Return false if the function FNDECL cannot be inlined on account of its
   attributes, true otherwise.  

References estimate_num_insns(), gsi_end_p(), gsi_next(), and gsi_stmt().

static bool gimple_expand_calls_inline ( )
static
   Expand call statements reachable from STMT_P.
   We can only have CALL_EXPRs as the "toplevel" tree code or nested
   in a MODIFY_EXPR.  
static bool has_abnormal_outgoing_edge_p ( )
inlinestatic
   Return true if BB has at least one abnormal outgoing edge.  
static tree has_label_address_in_static_1 ( )
static
   Callback through walk_tree.  Determine if a DECL_INITIAL makes reference
   to a local label.  

References targetm.

void init_inline_once ( void  )
   Initializes weights used by estimate_num_insns.  
     Estimating time for call is difficult, since we have no idea what the
     called function does.  In the current uses of eni_time_weights,
     underestimating the cost does less harm than overestimating it, so
     we choose a rather small value here.  

References copy_body_data::block.

static void initialize_cfun ( )
static
   Build struct function and associated datastructures for the new clone
   NEW_FNDECL to be build.  CALLEE_FNDECL is the original.  Function changes
   the cfun to the function of new_fndecl (and current_function_decl too).  
     Register specific tree functions.  
     Get clean struct function.  
     We will rebuild these, so just sanity check that they are empty.  
     Copy items we preserve during cloning.  

References basic_block_def::aux, loop::header, and basic_block_def::loop_father.

static void initialize_inlined_parameters ( copy_body_data id,
gimple  stmt,
tree  fn,
basic_block  bb 
)
static
   Generate code to initialize the parameters of the function at the
   top of the stack in ID from the GIMPLE_CALL STMT.  
     Figure out what the parameters are.  
     Loop through the parameter declarations, replacing each with an
     equivalent VAR_DECL, appropriately initialized.  
     After remapping parameters remap their types.  This has to be done
     in a second loop over all parameters to appropriately remap
     variable sized arrays when the size is specified in a
     parameter following the array.  
             Also remap the default definition if it was remapped
             to the default definition of the parameter replacement
             by the parameter setup.  
     Initialize the static chain.  
         No static chain?  Seems like a bug in tree-nested.c.  
static bool inline_forbidden_p ( )
static
   Return true if FNDECL is a function that cannot be inlined into
   another one.  
     First check for shared reasons not to copy the code.  
     Next, walk the statements of the function looking for
     constraucts we can't handle, or are non-optimal for inlining.  
static tree inline_forbidden_p_stmt ( gimple_stmt_iterator gsi,
bool *  handled_ops_p,
struct walk_stmt_info wip 
)
static
   A callback for walk_gimple_seq to handle statements.  Returns non-null
   iff a function can not be inlined.  Also sets the reason why. 
         Refuse to inline alloca call unless user explicitly forced so as
         this may change program's memory overhead drastically when the
         function using alloca is called in loop.  In GCC present in
         SPEC2000 inlining into schedule_block cause it to require 2GB of
         RAM instead of 256MB.  Don't do so for alloca calls emitted for
         VLA objects as those can't cause unbounded growth (they're always
         wrapped inside stack_save/stack_restore regions.  
         We cannot inline functions that call setjmp.  
               We cannot inline functions that take a variable number of
               arguments.  
               We can't inline functions that call __builtin_longjmp at
               all.  The non-local goto machinery really requires the
               destination be in a different function.  If we allow the
               function calling __builtin_longjmp to be inlined into the
               function calling __builtin_setjmp, Things will Go Awry.  
               Similarly.  
               If a __builtin_apply_args caller would be inlined,
               it would be saving arguments of the function it has
               been inlined into.  Similarly __builtin_return would
               return from the function the inline has been inlined into.  
         We will not inline a function which uses computed goto.  The
         addresses of its local labels, which may be tucked into
         global storage, are of course not constant across
         instantiations, which causes unexpected behavior.  

References HOST_WIDE_INT, int_size_in_bytes(), and targetm.

static void insert_debug_decl_map ( )
static
   Insert a tree->tree mapping for ID.  This is only used for
   variables.  

Referenced by copy_tree_body().

void insert_decl_map ( )
   Insert a tree->tree mapping for ID.  Despite the name suggests
   that the trees should be variables, it is used for more than that.  
     Always insert an identity map as well.  If we see this same new
     node again, we won't want to duplicate it a second time.  

Referenced by copy_tree_body(), remap_decl(), and self_inlining_addr_expr().

static gimple insert_init_debug_bind ( copy_body_data id,
basic_block  bb,
tree  var,
tree  value,
gimple  base_stmt 
)
static
   Append to BB a debug annotation that binds VAR to VALUE, inheriting
   lexical block and line number information from base_stmt, if given,
   or from the last stmt of the block otherwise.  

Referenced by copy_tree_body(), and self_inlining_addr_expr().

static void insert_init_stmt ( )
static
     If VAR represents a zero-sized variable, it's possible that the
     assignment statement may result in no gimple statements.  
         We can end up with init statements that store to a non-register
         from a rhs with a conversion.  Handle that here by forcing the
         rhs into a temporary.  gimple_regimplify_operands is not
         prepared to do this for us.  
static bool is_parm ( )
static
   Return true if DECL is a parameter or a SSA_NAME for a parameter.  
static tree mark_local_labels_stmt ( gimple_stmt_iterator gsip,
bool *  handled_ops_p,
struct walk_stmt_info wi 
)
static
   Called via walk_gimple_seq.  If *GSIP points to a GIMPLE_LABEL for a local
   label, copies the declaration and enters it in the splay_tree in DATA (which
   is really a 'copy_body_data *'.  
         Copy the decl and remember the copy.  

References lang_hooks::dup_lang_specific_decl, and remap_decl().

tree maybe_inline_call_in_expr ( )
   EXP is CALL_EXPR present in a GENERIC expression tree.  Try to integrate
   the callee and return the inlined body on success.  
     We can only try to inline "const" functions.  
         Remap the parameters.  
         Make sure not to unshare trees behind the front-end's back
         since front-end specific mechanisms may rely on sharing.  
         We're not inside any EH region.  
         We can only return something suitable for use in a GENERIC
         expression tree.  

Referenced by find_placeholder_in_expr().

static void maybe_move_debug_stmts_to_successors ( )
static
   Helper function for copy_cfg_body.  Move debug stmts from the end
   of NEW_BB to the beginning of successor basic blocks when needed.  If the
   successor has multiple predecessors, reset them, otherwise keep
   their value.  
             For the last edge move the debug stmts instead of copying
             them.  
unsigned int optimize_inline_calls ( )
   Expand calls to inline functions in the body of FN.  
     Clear out ID.  
     Or any functions that aren't finished yet.  
     We make no attempts to keep dominance info up-to-date.  
     Register specific gimple functions.  
     Reach the trees by walking over the CFG, and note the
     enclosing basic-blocks in the call edges.  
     We walk the blocks going forward, because inlined function bodies
     will split id->current_basic_block, and the new blocks will
     follow it; we'll trudge through them, processing their CALL_EXPRs
     along the way.  
     Fold queued statements.  
     If we didn't inline into the function there is nothing to do.  
     Renumber the lexical scoping (non-code) blocks consecutively.  
     It would be nice to check SSA/CFG/statement consistency here, but it is
     not possible yet - the IPA passes might make various functions to not
     throw and they don't care to proactively update local EH info.  This is
     done later in fixup_cfg pass that also execute the verification.  
static void prepend_lexical_block ( tree  current_block,
tree  new_block 
)
static
static void prepend_lexical_block ( )
static
   Install new lexical TREE_BLOCK underneath 'current_block'.  
void redirect_all_calls ( )
   Call cgraph_redirect_edge_call_stmt_to_callee on all calls in BB 
static void remap_block ( tree ,
copy_body_data  
)
static
static void remap_block ( )
static
   Copy the BLOCK to contain remapped versions of the variables
   therein.  And hook the new block into the block-tree.  
     Make the new block.  
     Remap its variables.  
     Remember the remapped block.  
static tree remap_blocks ( )
static
   Copy the whole block tree and root it in id->block.  
     Blocks are in arbitrary order, but make things slightly prettier and do
     not swap order when producing a copy.  
static void remap_blocks_to_null ( )
static
   Remap the block tree rooted at BLOCK to nothing.  
tree remap_decl ( )
   Remap DECL during the copying of the BLOCK tree for the function.  
     We only remap local variables in the current function.  
     See if we have remapped this declaration.  
     If we didn't already have an equivalent for this declaration,
     create one now.  
         Make a copy of the variable or label.  
         Remember it, so that if we encounter this local entity again
         we can reuse this copy.  Do this early because remap_type may
         need this decl for TYPE_STUB_DECL.  
         Remap types, if necessary.  
         Remap sizes as necessary.  
         If fields, do likewise for offset and qualifier.  

References copy_tree_body_r(), insert_decl_map(), remap_type(), and gdbhooks::TYPE_DECL.

Referenced by mark_local_labels_stmt().

static tree remap_decl_1 ( )
static
   Wrapper for remap_decl so it can be used as a callback.  

References alloc_loop(), bitmap_bit_p(), copy_body_data::blocks_to_copy, loop::header, basic_block_def::index, and loop::inner.

static tree remap_decls ( tree  decls,
vec< tree, va_gc > **  nonlocalized_list,
copy_body_data id 
)
static
     Remap its variables.  
             We need to add this variable to the local decls as otherwise
             nothing else will do so.  
         Remap the variable.  
         If we didn't remap this variable, we can't mess with its
         TREE_CHAIN.  If we remapped this variable to the return slot, it's
         already declared somewhere else, so don't declare it here.  
             Also copy value-expressions.  
static int remap_eh_region_nr ( )
static
   Helper for remap_gimple_stmt.  Given an EH region number for the
   source function, map that to the duplicate EH region number in
   the destination function.  
static tree remap_eh_region_tree_nr ( )
static
   Similar, but operate on INTEGER_CSTs.  
static tree remap_gimple_op_r ( )
static
   Remap the GIMPLE operand pointed to by *TP.  DATA is really a
   'struct walk_stmt_info *'.  DATA->INFO is a 'copy_body_data *'.
   WALK_SUBTREES is used to indicate walk_gimple_op whether to keep
   recursing into the children nodes of *TP.  
         Local variables and labels need to be replaced by equivalent
         variables.  We don't want to copy static variables; there's
         only one of those, no matter how many times we inline the
         containing function.  Similarly for globals from an outer
         function.  
         Remap the declaration.  
         Replace this variable with the copy.  
         ???  The C++ frontend uses void * pointer zero to initialize
         any other type.  This confuses the middle-end type verification.
         As cloned bodies do not go through gimplification again the fixup
         there doesn't trigger.  
       These may need to be remapped for EH handling.  
         If the enclosing record type is variably_modified_type_p, the field
         has already been remapped.  Otherwise, it need not be.  
       Types may need remapping as well.  
         If this is a constant, we have to copy the node iff the type
         will be remapped.  copy_tree_r will not copy a constant.  
         Otherwise, just copy the node.  Note that copy_tree_r already
         knows not to copy VAR_DECLs, etc., so this is safe.  
             We need to re-canonicalize MEM_REFs from inline substitutions
             that can happen when a pointer argument is an ADDR_EXPR.
             Recurse here manually to allow that.  
             We cannot propagate the TREE_THIS_NOTRAP flag if we have
             remapped a parameter as the property might be valid only
             for the parameter itself.  
         Here is the "usual case".  Copy this tree node, and then
         tweak some special cases.  
             The copied TARGET_EXPR has never been expanded, even if the
             original node was expanded already.  
             Variable substitution need not be simple.  In particular,
             the MEM_REF substitution above.  Make sure that
             TREE_CONSTANT and friends are up-to-date.  
             If this used to be invariant, but is not any longer,
             then regimplification is probably needed.  
     Update the TREE_BLOCK for the cloned expr.  
     Keep iterating.  

References build_int_cst_wide(), copy_node(), and remap_type().

static gimple_seq remap_gimple_seq ( )
static
   Create a new gimple_seq by remapping all the statements in BODY
   using the inlining information in ID.  
static gimple remap_gimple_stmt ( gimple  ,
copy_body_data  
)
static
static gimple remap_gimple_stmt ( )
static
   Helper for copy_bb.  Remap statement STMT using the inlining
   information in ID.  Return the new statement copy.  
     Begin by recognizing trees that we'll completely rewrite for the
     inlining context.  Our output for these trees is completely
     different from out input (e.g. RETURN_EXPR is deleted, and morphs
     into an edge).  Further down, we'll handle trees that get
     duplicated and/or tweaked.  
     When requested, GIMPLE_RETURNs should be transformed to just the
     contained GIMPLE_ASSIGN.  The branch semantics of the return will
     be handled elsewhere by manipulating the CFG rather than the
     statement.  
         If we're returning something, just turn that into an
         assignment into the equivalent of the original RESULT_DECL.
         If RETVAL is just the result decl, the result decl has
         already been set (e.g. a recent "foo (&result_decl, ...)");
         just toss the entire GIMPLE_RETURN.  
             id->retvar is already substituted.  Skip it on later remapping.  
         When cloning bodies from the C++ front end, we will be handed bodies
         in High GIMPLE form.  Handle here all the High GIMPLE statements that
         have embedded statements.  
             Here we handle statements that are not completely rewritten.
             First we detect some inlining-induced bogosities for
             discarding.  
             Some assignments VAR = VAR; don't generate any rtl code
             and thus don't count as variable modification.  Avoid
             keeping bogosities like 0 = 0.  
         For *ptr_N ={v} {CLOBBER}, if ptr_N is SSA_NAME defined
         in a block that we aren't copying during tree_function_versioning,
         just drop the clobber stmt.  
         Create a new deep copy of the statement.  
         Remap the region numbers for __builtin_eh_{pointer,filter},
         RESX and EH_DISPATCH.  
                       FALLTHRU 
                 Reset alias info if we didn't apply measures to
                 keep it valid over inlining by setting DECL_PT_UID.  
     If STMT has a block defined, map it to the newly constructed
     block.  
     Remap all the operands in COPY.  
     Clear the copied virtual operands.  We are not remapping them here
     but are going to recreate them from scratch.  
static void remap_save_expr ( tree ,
void *  ,
int *   
)
static
static void remap_save_expr ( )
static
   The SAVE_EXPR pointed to by TP is being copied.  If ST contains
   information indicating to what new SAVE_EXPR this one should be mapped,
   use that one.  Otherwise, create a new node and enter it in ST.  FN is
   the function into which the copy will be placed.  
     See if we already encountered this SAVE_EXPR.  
     If we didn't already remap this SAVE_EXPR, do so now.  
         Remember this SAVE_EXPR.  
         Make sure we don't remap an already-remapped SAVE_EXPR.  
         We've already walked into this SAVE_EXPR; don't do it again.  
     Replace this SAVE_EXPR with the copy.  
static tree remap_ssa_name ( )
static
   Construct new SSA name for old NAME. ID is the inline context.  
     Remap anonymous SSA names or SSA names of anonymous decls.  
         At least IPA points-to info can be directly transferred.  
     Do not set DEF_STMT yet as statement is not copied yet. We do that
     in copy_bb.  
     We might've substituted constant or another SSA_NAME for
     the variable.

     Replace the SSA name representing RESULT_DECL by variable during
     inlining:  this saves us from need to introduce PHI node in a case
     return value is just partly initialized.  
         At least IPA points-to info can be directly transferred.  
             By inlining function having uninitialized variable, we might
             extend the lifetime (variable might get reused).  This cause
             ICE in the case we end up extending lifetime of SSA name across
             abnormal edge, but also increase register pressure.

             We simply initialize all uninitialized vars by 0 except
             for case we are inlining to very first BB.  We can avoid
             this for all BBs that are not inside strongly connected
             regions of the CFG, but this is expensive to test.  

References copy_body_data::decl_map, copy_body_data::entry_bb, gsi_after_labels(), gsi_insert_before(), GSI_SAME_STMT, pointer_map_contains(), single_succ(), and single_succ_p().

Referenced by copy_gimple_bind().

tree remap_type ( )
     See if we have remapped this type.  
     The type only needs remapping if it's variably modified.  

References auto_var_in_fn_p(), and copy_body_data::src_fn.

Referenced by copy_tree_body_r(), finalize_task_copyfn(), remap_decl(), and remap_gimple_op_r().

static tree remap_type_1 ( )
static
     We do need a copy.  build and register it now.  If this is a pointer or
     reference type, remap the designated type and make a new pointer or
     reference type.  
     This is a new type, not a copy of an old type.  Need to reassociate
     variants.  We can handle everything except the main variant lazily.  
     Lazily create pointer and reference types.  
         Shouldn't have been thought variable sized.  
static tree replace_locals_op ( )
static
   Called via walk_gimple_seq by copy_gimple_seq_and_replace_local.
   Using the splay_tree pointed to by ST (which is really a `splay_tree'),
   remaps all local declarations to appropriate replacements in gimple
   operands. 
     Only a local declaration (variable or label).  
         Lookup the declaration.  
         If it's there, remap it.  
         Don't mess with a TARGET_EXPR that hasn't been expanded.
         It's OK for this to happen if it was part of a subtree that
         isn't immediately expanded, such as operand 2 of another
         TARGET_EXPR.  
     Keep iterating.  

References cgraph_edge::callee, CB_CGE_MOVE_CLONES, cgraph_remove_edge(), cgraph_remove_node_and_inline_clones(), changed, cgraph_node::clone_of, cgraph_node::clones, copy_body_data::dst_node, find_unreachable_blocks(), basic_block_def::flags, gsi_end_p(), gsi_next(), gsi_start_bb(), gsi_stmt(), cgraph_edge::inline_failed, ipa_remove_stmt_references(), basic_block_def::next_bb, cgraph_node::next_sibling_clone, and copy_body_data::transform_call_graph_edges.

static tree replace_locals_stmt ( gimple_stmt_iterator gsip,
bool *  handled_ops_p,
struct walk_stmt_info wi 
)
static
   Called via walk_gimple_seq by copy_gimple_seq_and_replace_local.
   Using the splay_tree pointed to by ST (which is really a `splay_tree'),
   remaps all local declarations to appropriate replacements in gimple
   statements. 
         This will remap a lot of the same decls again, but this should be
         harmless.  
     Keep iterating.  
static bool self_inlining_addr_expr ( )
static
   Return true if VALUE is an ADDR_EXPR of an automatic variable
   defined in function FN, or of a data member thereof.  

References insert_decl_map(), and insert_init_debug_bind().

static gimple setup_one_parameter ( copy_body_data id,
tree  p,
tree  value,
tree  fn,
basic_block  bb,
tree vars 
)
static
   Initialize parameter P with VALUE.  If needed, produce init statement
   at the end of BB.  When BB is NULL, we return init statement to be
   output later.  
         If we can match up types by promotion/demotion do so.  
             ???  For valid programs we should not end up here.
             Still if we end up with truly mismatched types here, fall back
             to using a VIEW_CONVERT_EXPR or a literal zero to not leak invalid
             GIMPLE to the following passes.  
     Make an equivalent VAR_DECL.  Note that we must NOT remap the type
     here since the type of this decl must be visible to the calling
     function.  
     Declare this new variable.  
     Make gimplifier happy about this variable.  
     If the parameter is never assigned to, has no SSA_NAMEs created,
     we would not need to create a new variable here at all, if it
     weren't for debug info.  Still, we can just use the argument
     value.  
         We may produce non-gimple trees by adding NOPs or introduce
         invalid sharing when operand is not really constant.
         It is not big deal to prohibit constant propagation here as
         we will constant propagate in DOM1 pass anyway.  
             We have to be very careful about ADDR_EXPR.  Make sure
             the base variable isn't a local variable of the inlined
             function, e.g., when doing recursive inlining, direct or
             mutually-recursive or whatever, which is why we don't
             just test whether fn == current_function_decl.  
     Register the VAR_DECL as the equivalent for the PARM_DECL;
     that way, when the PARM_DECL is encountered, it will be
     automatically replaced by the VAR_DECL.  
     Even if P was TREE_READONLY, the new VAR should not be.
     In the original code, we would have constructed a
     temporary, and then the function body would have never
     changed the value of P.  However, now, we will be
     constructing VAR directly.  The constructor body may
     change its value multiple times as it is being
     constructed.  Therefore, it must not be TREE_READONLY;
     the back-end assumes that TREE_READONLY variable is
     assigned to only once.  
     If there is no setup required and we are in SSA, take the easy route
     replacing all SSA names representing the function parameter by the
     SSA name passed to function.

     We need to construct map for the variable anyway as it might be used
     in different SSA names when parameter is set in function.

     Do replacement at -O0 for const arguments replaced by constant.
     This is important for builtin_constant_p and other construct requiring
     constant argument to be visible in inlined function body.  
     If the value of argument is never used, don't care about initializing
     it.  
     Initialize this VAR_DECL from the equivalent argument.  Convert
     the argument to the proper type in case it was promoted.  
         If we are in SSA form properly remap the default definition
         or assign to a dummy SSA name if the parameter is unused and
         we are not optimizing.  

Referenced by copy_result_decl_to_var().

void tree_function_versioning ( tree  old_decl,
tree  new_decl,
vec< ipa_replace_map_p, va_gc > *  tree_map,
bool  update_clones,
bitmap  args_to_skip,
bool  skip_return,
bitmap  blocks_to_copy,
basic_block  new_entry 
)
@verbatim 

Create a copy of a function's tree. OLD_DECL and NEW_DECL are FUNCTION_DECL tree nodes of the original function and the new copied function respectively. In case we want to replace a DECL tree with another tree while duplicating the function's body, TREE_MAP represents the mapping between these trees. If UPDATE_CLONES is set, the call_stmt fields of edges of clones of the function will be updated.

If non-NULL ARGS_TO_SKIP determine function parameters to remove from new version. If SKIP_RETURN is true, the new version will return void. If non-NULL BLOCK_TO_COPY determine what basic blocks to copy. If non_NULL NEW_ENTRY determine new entry BB of the clone.

     Copy over debug args.  
     Output the inlining info for this abstract function, since it has been
     inlined.  If we don't do this now, we can lose the information about the
     variables in the function when the blocks get blown away as soon as we
     remove the cgraph node.  
     Prepare the data structures for the tree copy.  
     Generate a new name for the new version. 
     Copy the function's static chain.  
     If there's a tree_map, prepare for substitution.  
     Copy the function's arguments.  
       Add local vars.  
     Set up the destination functions loop tree.  
     Copy the Function's body.  
     Renumber the lexical scoping (non-code) blocks consecutively.  
     We want to create the BB unconditionally, so that the addition of
     debug stmts doesn't affect BB count, which may in the end cause
     codegen differences.  
     Remap the nonlocal_goto_save_area, if any.  
     Clean up.  
     After partial cloning we need to rescale frequencies, so they are
     within proper range in the cloned function.  
bool tree_inlinable_function_p ( )
   Returns nonzero if FN is a function that does not have any
   fundamental inline blocking properties.  
     If we've already decided this function shouldn't be inlined,
     there's no need to check again.  
     We only warn for functions declared `inline' by the user.  
         See if we should warn about uninlinable functions.  Previously,
         some of these warnings would be issued while trying to expand
         the function inline, but that would cause multiple warnings
         about functions that would for example call alloca.  But since
         this a property of the function, just one warning is enough.
         As a bonus we can now give more details about the reason why a
         function is not inlinable.  
     Squirrel away the result so that we don't have to check again.  
bool tree_versionable_function_p ( )
   Return true if the function is allowed to be versioned.
   This is a guard for the versioning functionality.  

Referenced by spread_undeadness().

static void update_clone_info ( )
static
   Update clone info after duplication.  
         First update replace maps to match the new body.  
static void update_ssa_across_abnormal_edges ( basic_block  bb,
basic_block  ret_bb,
bool  can_throw,
bool  nonlocal_goto 
)
static
   Inserting Single Entry Multiple Exit region in SSA form into code in SSA
   form is quite easy, since dominator relationship for old basic blocks does
   not change.

   There is however exception where inlining might change dominator relation
   across EH edges from basic block within inlined functions destinating
   to landing pads in function we inline into.

   The function fills in PHI_RESULTs of such PHI nodes if they refer
   to gimple regs.  Otherwise, the function mark PHI_RESULT of such
   PHI nodes for renaming.  For non-gimple regs, renaming is safe: the
   EH edges are abnormal and SSA_NAME_OCCURS_IN_ABNORMAL_PHI must be
   set, and this means that there will be no overlapping live ranges
   for the underlying symbol.

   This might change in future if we allow redirecting of EH edges and
   we might want to change way build CFG pre-inlining to include
   all the possible edges then.  
               For abnormal goto/call edges the receiver can be the
               ENTRY_BLOCK.  Do not assert this cannot happen.  

Variable Documentation

eni_weights eni_size_weights
@verbatim 

Tree inlining. Copyright (C) 2001-2013 Free Software Foundation, Inc. Contributed by Alexandre Oliva aoliv.nosp@m.a@re.nosp@m.dhat..nosp@m.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 count_insns(), and tree_ssa_unswitch_loops().

eni_weights eni_time_weights
   Weights that estimate_num_insns uses to estimate the time necessary
   to execute the produced code.  
const char* inline_forbidden_reason
static
int processing_debug_stmt = 0
static
   If nonzero, we're remapping the contents of inlined debug
   statements.  If negative, an error has occurred, such as a
   reference to a variable that isn't available in the inlined
   context.