GCC Middle and Back End API Reference
ipa-sra.cc File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "backend.h"
#include "tree.h"
#include "gimple.h"
#include "predict.h"
#include "tree-pass.h"
#include "ssa.h"
#include "cgraph.h"
#include "gimple-pretty-print.h"
#include "alias.h"
#include "tree-eh.h"
#include "gimple-iterator.h"
#include "gimple-walk.h"
#include "tree-dfa.h"
#include "tree-sra.h"
#include "alloc-pool.h"
#include "symbol-summary.h"
#include "dbgcnt.h"
#include "tree-inline.h"
#include "ipa-utils.h"
#include "builtins.h"
#include "cfganal.h"
#include "tree-streamer.h"
#include "internal-fn.h"
#include "symtab-clones.h"
#include "attribs.h"
#include "sreal.h"
#include "ipa-cp.h"
#include "ipa-prop.h"
#include "gt-ipa-sra.h"
Include dependency graph for ipa-sra.cc:

Data Structures

struct  param_access
 
struct  gensum_param_access
 
struct  isra_param_desc
 
struct  gensum_param_desc
 
class  isra_func_summary
 
struct  isra_param_flow
 
class  isra_call_summary
 
class  ipa_sra_function_summaries
 
class  ipa_sra_call_summaries
 

Macros

#define ISRA_ARG_SIZE_LIMIT_BITS   16
 
#define ISRA_ARG_SIZE_LIMIT   (1 << ISRA_ARG_SIZE_LIMIT_BITS)
 
#define IPA_SRA_MAX_PARAM_FLOW_LEN   7
 

Functions

static void ipa_sra_summarize_function (cgraph_node *)
 
static void free_param_decl_accesses (isra_param_desc *desc)
 
ipa_opt_pass_dmake_pass_ipa_sra (gcc::context *ctxt)
 
void ipa_sra_cc_finalize (void)
 

Variables

static ipa_sra_function_summariesfunc_sums
 
static ipa_sra_call_summariescall_sums
 

Macro Definition Documentation

◆ IPA_SRA_MAX_PARAM_FLOW_LEN

#define IPA_SRA_MAX_PARAM_FLOW_LEN   7
How many parameters can feed into a call actual argument and still be
tracked.   

◆ ISRA_ARG_SIZE_LIMIT

#define ISRA_ARG_SIZE_LIMIT   (1 << ISRA_ARG_SIZE_LIMIT_BITS)

◆ ISRA_ARG_SIZE_LIMIT_BITS

#define ISRA_ARG_SIZE_LIMIT_BITS   16
Bits used to track size of an aggregate in bytes interprocedurally.   

Function Documentation

◆ free_param_decl_accesses()

static void free_param_decl_accesses ( isra_param_desc * desc)
static
Properly deallocate accesses of DESC.  TODO: Since this data structure is
allocated in GC memory, this is not necessary and we can consider removing
the function.   

References isra_param_desc::accesses, ggc_free(), i, vec_free(), and vec_safe_length().

Referenced by isra_func_summary::zap(), and isra_func_summary::~isra_func_summary().

◆ ipa_sra_cc_finalize()

void ipa_sra_cc_finalize ( void )
Reset all state within ipa-sra.cc so that we can rerun the compiler
within the same process.  For use by toplev::finalize.   

References call_sums, func_sums, ggc_delete(), and NULL.

Referenced by toplev::finalize().

◆ ipa_sra_summarize_function()

static void ipa_sra_summarize_function ( cgraph_node * node)
static
Interprocedural scalar replacement of aggregates
   Copyright (C) 2019-2024 Free Software Foundation, Inc.
   Contributed by Martin Jambor <mjambor@suse.cz>

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/>.   
IPA-SRA is an interprocedural pass that removes unused function return
values (turning functions returning a value which is never used into void
functions) and removes unused function parameters.  It can also replace an
aggregate parameter by a set of other parameters representing part of the
original, turning those passed by reference into new ones which pass the
value directly.

The pass is a true IPA one, which means that it works in three stages in
order to be able to take advantage of LTO.  First, summaries about functions
and each calls are generated.  Function summaries (often called call graph
node summaries) contain mainly information about which parameters are
potential transformation candidates and which bits of candidates are
accessed.  We differentiate between accesses done as a part of a call
statement (which might be not necessary if the callee is also transformed)
and others (which are mandatory).  Call summaries (often called call graph
edge summaries) contain information about which function formal parameters
feed into which actual call arguments so that if two parameters are only
used in a sum which is then passed to another function which then however
does not use this parameter, all three parameters of the two functions can
be eliminated.  Edge summaries also have flags whether the return value is
used or if it is only returned in the caller too.  In LTO mode these
summaries are then streamed to the object file in the compilation phase and
streamed back in in the WPA analysis stage.

The interprocedural analysis phase traverses the graph in topological order
in two sweeps, one in each direction.  First, from callees to callers for
parameter removal and splitting.  Each strongly-connected component is
processed iteratively until the situation in it stabilizes.  The pass from
callers to callees is then carried out to remove unused return values in a
very similar fashion.

Because parameter manipulation has big implications for call redirection
which is done only after all call graph nodes materialize, the
transformation phase is not part of this patch but is carried out by the
clone materialization and edge redirection itself, see comments in
ipa-param-manipulation.h for more details.   
Intraprocedural part of IPA-SRA analysis.  Scan function body of NODE and
create a summary structure describing IPA-SRA opportunities and constraints
in it.   

References BITMAP_ALLOC, BITMAP_FREE, count, symtab_node::decl, DECL_ARGUMENTS, DECL_CHAIN, DECL_STRUCT_FUNCTION, dump_file, free(), func_sums, gcc_obstack_init, ggc_alloc(), last_basic_block_for_fn, symtab_node::name(), NULL, opt_for_fn, symtab_node::order, pop_cfun(), push_cfun(), scan_function(), TREE_CODE, and TREE_TYPE.

Referenced by ipa_sra_function_summaries::insert().

◆ make_pass_ipa_sra()

ipa_opt_pass_d * make_pass_ipa_sra ( gcc::context * ctxt)

References ggc_alloc().

Variable Documentation

◆ call_sums

ipa_sra_call_summaries* call_sums
static

Referenced by ipa_sra_cc_finalize().

◆ func_sums

ipa_sra_function_summaries* func_sums
static
Pointer to the pass function summary holder.   

Referenced by ipa_sra_function_summaries::insert(), ipa_sra_cc_finalize(), and ipa_sra_summarize_function().