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

Functions

static void update_noncloned_frequencies (struct cgraph_node *node, int freq_scale)
static bool can_remove_node_now_p_1 ()
static bool can_remove_node_now_p ()
void clone_inlined_nodes (struct cgraph_edge *e, bool duplicate, bool update_original, int *overall_size)
bool inline_call (struct cgraph_edge *e, bool update_original, vec< cgraph_edge_p > *new_edges, int *overall_size, bool update_overall_summary)
static struct cgraph_nodesave_inline_function_body ()
static bool preserve_function_body_p ()
unsigned int inline_transform ()

Variables

int ncalls_inlined
int nfunctions_inlined
bool speculation_removed

Function Documentation

static bool can_remove_node_now_p ( )
static
   We are going to eliminate last direct call to NODE (or alias of it) via edge E.
   Verify that the NODE can be removed from unit and if it is contained in comdat
   group that the whole comdat group is removable.  
     When we see same comdat group, we need to be sure that all
     items can be removed.  

Referenced by clone_inlined_nodes().

static bool can_remove_node_now_p_1 ( )
static
   We removed or are going to remove the last call to NODE.
   Return true if we can and want proactively remove the NODE now.
   This is important to do, since we want inliner to know when offline
   copy of function was removed.  
     FIXME: When address is taken of DECL_EXTERNAL function we still
     can remove its offline copy, but we would need to keep unanalyzed node in
     the callgraph so references can point to it.  
             Inlining might enable more devirtualizing, so we want to remove
             those only after all devirtualizable virtual calls are processed.
             Lacking may edges in callgraph we just preserve them post
             inlining.  
             During early inlining some unanalyzed cgraph nodes might be in the
             callgraph and they might reffer the function in question.  
void clone_inlined_nodes ( struct cgraph_edge e,
bool  duplicate,
bool  update_original,
int *  overall_size 
)
   E is expected to be an edge being inlined.  Clone destination node of
   the edge and redirect it to the new clone.
   DUPLICATE is used for bookkeeping on whether we are actually creating new
   clones or re-using node originally representing out-of-line function call.
         We may eliminate the need for out-of-line copy to be output.
         In that case just go ahead and re-use it.  This is not just an
         memory optimization.  Making offline copy of fuction disappear
         from the program will improve future decisions on inlining.  
             Recursive inlining never wants the master clone to
             be overwritten.  
             TODO: When callee is in a comdat group, we could remove all of it,
             including all inline clones inlined into it.  That would however
             need small function inlining to register edge removal hook to
             maintain the priority queue.

             For now we keep the ohter functions in the group in program until
             cgraph_remove_unreachable_functions gets rid of them.  
     Recursively clone all bodies.  

References cgraph_edge::callee, cgraph_node::callers, can_remove_node_now_p(), cgraph_clone_node(), cgraph_redirect_edge_callee(), cgraph_edge::count, symtab_node_base::decl, symtab_node_base::definition, symtab_node_base::externally_visible, cgraph_edge::frequency, cgraph_node::global, inline_summary(), cgraph_global_info::inlined_to, cgraph_edge::next_caller, nfunctions_inlined, inline_summary::size, symtab_dissolve_same_comdat_group_list(), update_noncloned_frequencies(), and vNULL.

bool inline_call ( struct cgraph_edge e,
bool  update_original,
vec< cgraph_edge_p > *  new_edges,
int *  overall_size,
bool  update_overall_summary 
)
   Mark edge E as inlined and update callgraph accordingly.  UPDATE_ORIGINAL
   specify whether profile of original function should be updated.  If any new
   indirect edges are discovered in the process, add them to NEW_EDGES, unless
   it is NULL. If UPDATE_OVERALL_SUMMARY is false, do not bother to recompute overall
   size of caller after inlining. Caller is required to eventually do it via
   inline_update_overall_summary.

   Return true iff any new callgraph edges were discovered as a
   result of inlining.  
     Don't inline inlined edges.  
     Don't even think of inlining inline clone.  
     If aliases are involved, redirect edge to the actual destination and
     possibly remove the aliases.  
     Verify that estimated growth match real growth.  Allow off-by-one
     error due to INLINE_SIZE_SCALE roudoff errors.  
                 FIXME: a hack.  Edges with false predicate are accounted
                 wrong, we should remove them from callgraph.  
     Account the change of overall unit size; external functions will be
     removed and are thus not accounted.  
     This must happen after inline_merge_summary that rely on jump
     functions of callee to not be updated.  

Referenced by flatten_function().

unsigned int inline_transform ( )
   Apply inline plan to function.  
     FIXME: Currently the pass manager is adding inline transform more than
     once to some clones.  This needs revisiting after WPA cleanups.  
     We might need the body of this function so that we can expand
     it inline somewhere else.  
       Redirecting edges might lead to a need for vops to be recomputed.  
static bool preserve_function_body_p ( )
static
   Return true when function body of DECL still needs to be kept around
   for later re-use.  
     Look if there is any clone around.  
static struct cgraph_node* save_inline_function_body ( )
staticread
   Copy function body of NODE and redirect all inline clones to it.
   This is done before inline plan is applied to NODE when there are
   still some inline clones if it.

   This is necessary because inline decisions are not really transitive
   and the other inline clones may have different bodies.  
     first_clone will be turned into real function.  
     Now reshape the clone tree, so all other clones descends from
     first_clone.  
     Now node in question has no clones.  
     Inline clones share decl with the function they are cloned
     from.  Walk the whole clone tree and redirect them all to the
     new decl.  
     Copy the OLD_VERSION_NODE function tree to the new version.  
     The function will be short lived and removed after we inline all the clones,
     but make it internal so we won't confuse ourself.  
     When doing recursive inlining, the clone may become unnecessary.
     This is possible i.e. in the case when the recursive function is proved to be
     non-throwing and the recursion happens only in the EH landing pad.
     We can not remove the clone until we are done with saving the body.
     Remove it now.  
static void update_noncloned_frequencies ( struct cgraph_node node,
int  freq_scale 
)
static
   Scale frequency of NODE edges by FREQ_SCALE.  
     We do not want to ignore high loop nest after freq drops to 0.  

References cgraph_edge::callee, cgraph_edge::frequency, and cgraph_edge::inline_failed.

Referenced by clone_inlined_nodes().


Variable Documentation

int ncalls_inlined
@verbatim 

Callgraph transformations to handle inlining Copyright (C) 2003-2013 Free Software Foundation, Inc. Contributed by Jan Hubicka

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/.

   The inline decisions are stored in callgraph in "inline plan" and
   applied later.

   To mark given call inline, use inline_call function.
   The function marks the edge inlinable and, if necessary, produces
   virtual clone in the callgraph representing the new copy of callee's
   function body.

   The inline plan is applied on given function body by inline_transform.  
int nfunctions_inlined

Referenced by clone_inlined_nodes().

bool speculation_removed