2005-08-01 09:26:30 +02:00
|
|
|
/* Interprocedural constant propagation
|
2011-03-05 00:07:20 +01:00
|
|
|
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
|
Make-lang.in, [...]: Update copyright years.
* ada/gcc-interface/Make-lang.in, alias.c, attribs.c, auto-inc-dec.c,
basic-block.h, bb-reorder.c, calls.c, c-common.c, cgraph.h,
collect2.h, config/alpha/alpha.c, config/alpha/alpha.md,
config/alpha/predicates.md, config/arm/arm.md,
config/arm/lib1funcs.asm, config/arm/neon-schedgen.ml,
config/avr/avr.c, config/avr/avr.md, config/bfin/bfin.c,
config/darwin9.h, config/darwin.c, config/darwin.h,
config/h8300/h8300.c, config/i386/cpuid.h, config/i386/cygming.h,
config/i386/cygwin.h, config/i386/mingw32.h, config/i386/msformat-c.c,
config/i386/sol2-10.h, config/i386/xopintrin.h, config/ia64/ia64.c,
config/ia64/ia64.md, config/ia64/sync.md, config/mep/mep.c,
config/mips/mips.md, config/mn10300/mn10300.c,
config/mn10300/mn10300.h, config/pa/pa.c, config/pa/pa.md,
config/rs6000/aix.h, config/rs6000/dfp.md,
config/rs6000/rs6000-builtin.def, config/rs6000/rs6000-c.c,
config/rs6000/vector.md, config/rtems.h, config/rx/rx.md,
config/s390/s390.md, config/sol2-c.c, config/sparc/sol2-bi.h,
config/sparc/sol2-gas.h, config/sparc/sparc.h, config/sparc/sparc.md,
config/sparc/sparc-protos.h, config/spu/spu.c, config/spu/spu-c.c,
config/t-darwin, convert.c, c.opt, c-opts.c, cp/Make-lang.in,
c-pretty-print.c, c-typeck.c, df-core.c, df-scan.c, diagnostic.c,
diagnostic.h, doc/cppopts.texi, doc/cpp.texi, doc/extend.texi,
doc/gimple.texi, doc/languages.texi, doc/plugins.texi, doc/rtl.texi,
doc/standards.texi, doc/tree-ssa.texi, doc/trouble.texi, dominance.c,
fold-const.c, fortran/Make-lang.in, fwprop.c, gcc-plugin.h,
gensupport.c, gimple.h, gimple-iterator.c, graphite.c,
graphite-clast-to-gimple.c, graphite-clast-to-gimple.h,
graphite-dependences.c, graphite-poly.c, graphite-poly.h,
graphite-ppl.c, graphite-ppl.h, graphite-scop-detection.c,
graphite-sese-to-poly.c, graphite-sese-to-poly.h, ifcvt.c, intl.c,
intl.h, ipa.c, ipa-cp.c, ipa-inline.c, ipa-prop.c, ipa-prop.h,
ipa-pure-const.c, ipa-reference.c, ipa-type-escape.c, ira-color.c,
ira-conflicts.c, ira-lives.c, java/Make-lang.in, lambda-code.c,
loop-invariant.c, lto/Make-lang.in, lto-streamer.h, lto-streamer-in.c,
objc/Make-lang.in, objcp/Make-lang.in, omp-low.c, optc-gen.awk,
opt-functions.awk, opth-gen.awk, params.def, passes.c,
postreload-gcse.c, print-tree.c, recog.c, regrename.c, reload.h,
rtl.def, sched-int.h, sched-rgn.c, sel-sched-dump.c, sese.c, sese.h,
store-motion.c, stor-layout.c, tree-cfgcleanup.c, tree-chrec.c,
tree-complex.c, tree-data-ref.c, tree.def, tree-eh.c, tree-flow.h,
tree-flow-inline.h, tree.h, tree-loop-distribution.c, tree-outof-ssa.c,
tree-parloops.c, tree-pass.h, tree-predcom.c, tree-profile.c,
tree-scalar-evolution.c, tree-ssa-address.c, tree-ssa-alias.c,
tree-ssa-coalesce.c, tree-ssa-copy.c, tree-ssa-dce.c, tree-ssa-dom.c,
tree-ssa-dse.c, tree-ssa-loop-im.c, tree-ssa-loop-ivcanon.c,
tree-ssa-loop-manip.c, tree-ssa-math-opts.c, tree-ssa-operands.c,
tree-ssa-pre.c, tree-ssa-sccvn.c, tree-ssa-structalias.c,
tree-ssa-uncprop.c, tree-tailcall.c, tree-vect-data-refs.c,
tree-vect-loop.c, tree-vectorizer.h, tree-vect-slp.c, tree-vrp.c,
unwind-dw2-fde-darwin.c, varpool.c: Update copyright years.
From-SVN: r157950
2010-04-02 21:54:46 +02:00
|
|
|
Free Software Foundation, Inc.
|
2005-08-01 09:26:30 +02:00
|
|
|
Contributed by Razya Ladelsky <RAZYA@il.ibm.com>
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
This file is part of GCC.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
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
|
2007-07-26 10:37:01 +02:00
|
|
|
Software Foundation; either version 3, or (at your option) any later
|
2005-08-01 09:26:30 +02:00
|
|
|
version.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
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.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-07-26 10:37:01 +02:00
|
|
|
along with GCC; see the file COPYING3. If not see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Interprocedural constant propagation. The aim of interprocedural constant
|
|
|
|
propagation (IPCP) is to find which function's argument has the same
|
|
|
|
constant value in each invocation throughout the whole program. For example,
|
|
|
|
consider the following program:
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
int g (int y)
|
|
|
|
{
|
|
|
|
printf ("value is %d",y);
|
|
|
|
}
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
int f (int x)
|
|
|
|
{
|
|
|
|
g (x);
|
|
|
|
}
|
2008-05-06 16:15:18 +02:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
int h (int y)
|
|
|
|
{
|
|
|
|
g (y);
|
|
|
|
}
|
2008-05-06 16:15:18 +02:00
|
|
|
|
|
|
|
void main (void)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
f (3);
|
|
|
|
h (3);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2009-11-25 11:55:54 +01:00
|
|
|
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
The IPCP algorithm will find that g's formal argument y is always called
|
|
|
|
with the value 3.
|
|
|
|
|
|
|
|
The algorithm used is based on "Interprocedural Constant Propagation", by
|
2011-02-11 16:16:46 +01:00
|
|
|
David Callahan, Keith D Cooper, Ken Kennedy, Linda Torczon, Comp86, pg
|
2008-05-06 16:15:18 +02:00
|
|
|
152-161
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
The optimization is divided into three stages:
|
|
|
|
|
|
|
|
First stage - intraprocedural analysis
|
|
|
|
=======================================
|
2008-05-06 16:15:18 +02:00
|
|
|
This phase computes jump_function and modification flags.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
A jump function for a callsite represents the values passed as an actual
|
|
|
|
arguments of a given callsite. There are three types of values:
|
|
|
|
Pass through - the caller's formal parameter is passed as an actual argument.
|
cfgloop.c, [...]: Fix comment typos.
* cfgloop.c, config/alpha/alpha.c, config/bfin/bfin.c,
config/i386/athlon.md, config/ia64/ia64.md,
config/rs6000/rs6000.c, config/s390/s390.c, config/spu/spu.md,
df-problems.c, df.h, fold-const.c, ipa-cp.c, ipa-inline.c,
ipa-prop.h, see.c, struct-equiv.c, tree-inline.c,
tree-ssa-loop-niter.c, tree-vect-analyze.c,
tree-vect-transform.c: Fix comment typos.
From-SVN: r122080
2007-02-18 01:52:51 +01:00
|
|
|
Constant - a constant is passed as an actual argument.
|
2005-08-01 09:26:30 +02:00
|
|
|
Unknown - neither of the above.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
The jump function info, ipa_jump_func, is stored in ipa_edge_args
|
2005-08-01 09:26:30 +02:00
|
|
|
structure (defined in ipa_prop.h and pointed to by cgraph_node->aux)
|
2008-05-06 16:15:18 +02:00
|
|
|
modified_flags are defined in ipa_node_params structure
|
2005-08-01 09:26:30 +02:00
|
|
|
(defined in ipa_prop.h and pointed to by cgraph_edge->aux).
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2010-08-05 15:23:07 +02:00
|
|
|
-ipcp_generate_summary() is the first stage driver.
|
2005-08-01 09:26:30 +02:00
|
|
|
|
|
|
|
Second stage - interprocedural analysis
|
|
|
|
========================================
|
|
|
|
This phase does the interprocedural constant propagation.
|
2008-05-06 16:15:18 +02:00
|
|
|
It computes lattices for all formal parameters in the program
|
|
|
|
and their value that may be:
|
2005-08-01 09:26:30 +02:00
|
|
|
TOP - unknown.
|
|
|
|
BOTTOM - non constant.
|
2008-05-06 16:15:18 +02:00
|
|
|
CONSTANT - constant value.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
Lattice describing a formal parameter p will have a constant value if all
|
|
|
|
callsites invoking this function have the same constant value passed to p.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
The lattices are stored in ipcp_lattice which is itself in ipa_node_params
|
|
|
|
structure (defined in ipa_prop.h and pointed to by cgraph_edge->aux).
|
2005-08-01 09:26:30 +02:00
|
|
|
|
|
|
|
-ipcp_iterate_stage() is the second stage driver.
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
Third phase - transformation of function code
|
2005-08-01 09:26:30 +02:00
|
|
|
============================================
|
|
|
|
Propagates the constant-valued formals into the function.
|
2008-05-06 16:15:18 +02:00
|
|
|
For each function whose parameters are constants, we create its clone.
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
Then we process the clone in two ways:
|
2005-08-01 09:26:30 +02:00
|
|
|
1. We insert an assignment statement 'parameter = const' at the beginning
|
2008-05-06 16:15:18 +02:00
|
|
|
of the cloned function.
|
|
|
|
2. For read-only parameters that do not live in memory, we replace all their
|
|
|
|
uses with the constant.
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2008-06-06 07:42:00 +02:00
|
|
|
We also need to modify some callsites to call the cloned functions instead
|
2008-05-06 16:15:18 +02:00
|
|
|
of the original ones. For a callsite passing an argument found to be a
|
2005-08-01 09:26:30 +02:00
|
|
|
constant by IPCP, there are two different cases to handle:
|
2008-05-06 16:15:18 +02:00
|
|
|
1. A constant is passed as an argument. In this case the callsite in the
|
|
|
|
should be redirected to call the cloned callee.
|
|
|
|
2. A parameter (of the caller) passed as an argument (pass through
|
|
|
|
argument). In such cases both the caller and the callee have clones and
|
|
|
|
only the callsite in the cloned caller is redirected to call to the
|
|
|
|
cloned callee.
|
|
|
|
|
2008-06-06 07:42:00 +02:00
|
|
|
This update is done in two steps: First all cloned functions are created
|
2008-05-06 16:15:18 +02:00
|
|
|
during a traversal of the call graph, during which all callsites are
|
|
|
|
redirected to call the cloned function. Then the callsites are traversed
|
|
|
|
and many calls redirected back to fit the description above.
|
2005-08-01 09:26:30 +02:00
|
|
|
|
|
|
|
-ipcp_insert_stage() is the third phase driver.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2010-08-05 15:23:07 +02:00
|
|
|
|
|
|
|
This pass also performs devirtualization - turns virtual calls into direct
|
|
|
|
ones if it can prove that all invocations of the function call the same
|
|
|
|
callee. This is achieved by building a list of all base types (actually,
|
|
|
|
their BINFOs) that individual parameters can have in an iterative matter
|
|
|
|
just like propagating scalar constants and then examining whether virtual
|
|
|
|
calls which take a parameter as their object fold to the same target for all
|
|
|
|
these types. If we cannot enumerate all types or there is a type which does
|
|
|
|
not have any BINFO associated with it, cannot_devirtualize of the associated
|
|
|
|
parameter descriptor is set which is an equivalent of BOTTOM lattice value
|
|
|
|
in standard IPA constant propagation.
|
2005-08-01 09:26:30 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "system.h"
|
|
|
|
#include "coretypes.h"
|
|
|
|
#include "tree.h"
|
|
|
|
#include "target.h"
|
2010-08-05 15:23:07 +02:00
|
|
|
#include "gimple.h"
|
2005-08-01 09:26:30 +02:00
|
|
|
#include "cgraph.h"
|
|
|
|
#include "ipa-prop.h"
|
|
|
|
#include "tree-flow.h"
|
|
|
|
#include "tree-pass.h"
|
|
|
|
#include "flags.h"
|
|
|
|
#include "timevar.h"
|
|
|
|
#include "diagnostic.h"
|
diagnostic.c: Don't include tm.h, tree.h, tm_p.h, langhooks.h or langhooks-def.h.
* diagnostic.c: Don't include tm.h, tree.h, tm_p.h, langhooks.h or
langhooks-def.h.
(diagnostic_initialize): Initialize x_data not last_function.
(diagnostic_report_current_function): Move to tree-diagnostic.c.
(default_diagnostic_starter): Call
diagnostic_report_current_module not
diagnostic_report_current_function.
(diagnostic_report_diagnostic): Initialize x_data not
abstract_origin.
(verbatim): Likewise.
* diagnostic.h (struct diagnostic_info): Change abstract_origin to
x_data.
(struct diagnostic_context): Change last_function to x_data.
(diagnostic_auxiliary_data): Replace with
diagnostic_context_auxiliary_data and
diagnostic_info_auxiliary_data.
(diagnostic_last_function_changed, diagnostic_set_last_function,
diagnostic_report_current_function): Move to tree-diagnostic.h.
(print_declaration, dump_generic_node, print_generic_stmt,
print_generic_stmt_indented, print_generic_expr,
print_generic_decl, debug_c_tree, dump_omp_clauses,
print_call_name, debug_generic_expr, debug_generic_stmt,
debug_tree_chain, default_tree_printer): Move to
tree-pretty-print.h.
(debug_gimple_stmt, debug_gimple_seq, print_gimple_seq,
print_gimple_stmt, print_gimple_expr, dump_gimple_stmt): Move to
gimple-pretty-print.h.
* pretty-print.c: Don't include tree.h
(pp_base_format): Don't handle %K here.
(pp_base_tree_identifier): Move to tree-pretty-print.c.
* pretty-print.h (text_info): Change abstract_origin to x_data.
(pp_tree_identifier, pp_unsupported_tree,
pp_base_tree_identifier): Move to tree-pretty-print.h.
* gimple-pretty-print.h, tree-diagnostic.c, tree-diagnostic.h,
tree-pretty-print.h: New files.
* tree-pretty-print.c: Include tree-pretty-print.h.
(percent_K_format): New. Moved from pretty-print.c.
(pp_base_tree_identifier): Move from pretty-print.c.
* c-objc-common.c: Include tree-pretty-print.h.
(c_tree_printer): Handle %K here.
* langhooks.c: Include tree-diagnostic.h.
(lhd_print_error_function): Use diagnostic_abstract_origin macro.
* toplev.c: Include tree-diagnostic.h and tree-pretty-print.h.
(default_tree_printer): Handle %K using percent_K_format.
(general_init): Use default_tree_diagnostic_starter.
* tree.c: Include tree-diagnostic.h and tree-pretty-print.h.
(free_lang_data): Use default_tree_diagnostic_starter.
* c-pretty-print.c: Include tree-pretty-print.h.
* cfgexpand.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* cgraphunit.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* dwarf2out.c: Include tree-pretty-print.h.
* except.c: Include tree-pretty-print.h.
* gimple-pretty-print.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* gimplify.c: Include tree-pretty-print.h.
* graphite-poly.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* ipa-cp.c: Include tree-pretty-print.h.
* ipa-inline.c: Include gimple-pretty-print.h.
* ipa-prop.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* ipa-pure-const.c: Include gimple-pretty-print.h.
* ipa-struct-reorg.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* ipa-type-escape.c: Include tree-pretty-print.h.
* print-rtl.c: Include tree-pretty-print.h.
* print-tree.c: Include gimple-pretty-print.h.
* sese.c: Include tree-pretty-print.h.
* tree-affine.c: Include tree-pretty-print.h.
* tree-browser.c: Include tree-pretty-print.h.
* tree-call-cdce.c: Include gimple-pretty-print.h.
* tree-cfg.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-chrec.c: Include tree-pretty-print.h.
* tree-data-ref.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-dfa.c: Include tree-pretty-print.h.
* tree-if-conv.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-inline.c: Include tree-pretty-print.h.
* tree-into-ssa.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-nrv.c: Include tree-pretty-print.h.
* tree-object-size.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-outof-ssa.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-parloops.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-predcom.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-scalar-evolution.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-sra.c: Include tree-pretty-print.h.
* tree-ssa-address.c: Include tree-pretty-print.h.
* tree-ssa-alias.c: Include tree-pretty-print.h.
* tree-ssa-ccp.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-coalesce.c: Include tree-pretty-print.h.
* tree-ssa-copy.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-copyrename.c: Include tree-pretty-print.h.
* tree-ssa-dce.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-dom.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-dse.c: Include gimple-pretty-print.h.
* tree-ssa-forwprop.c: Include tree-pretty-print.h.
* tree-ssa-ifcombine.c: Include tree-pretty-print.h.
* tree-ssa-live.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-im.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-ivcanon.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-ivopts.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-niter.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-loop-prefetch.c: Include tree-pretty-print.h.
* tree-ssa-math-opts.c: Include gimple-pretty-print.h.
* tree-ssa-operands.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-phiprop.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-pre.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-propagate.c: Include gimple-pretty-print.h.
* tree-ssa-reassoc.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-sccvn.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-sink.c: Include gimple-pretty-print.h.
* tree-ssa-ter.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-ssa-uninit.c: Include gimple-pretty-print.h.
* tree-ssa.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-stdarg.c: Include gimple-pretty-print.h.
* tree-switch-conversion.c: Include gimple-pretty-print.h.
* tree-tailcall.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-data-refs.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-loop-manip.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-loop.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-patterns.c: Include gimple-pretty-print.h.
* tree-vect-slp.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vect-stmts.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* tree-vectorizer.c: Include tree-pretty-print.h.
* tree-vrp.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* value-prof.c: Include tree-pretty-print.h and
gimple-pretty-print.h.
* var-tracking.c: Include tree-pretty-print.h.
* Makefile.in (OBJS-common): Add tree-diagnostic.o.
(tree-diagnostic.o): New dependencies.
(c-objc-common.o, c-pretty-print.o, langhooks.o, tree.o,
tree-inline.o, print-tree.o, stor-layout.o, tree-ssa-uninit.o,
tree-ssa.o, tree-into-ssa.o, tree-ssa-ter.o, tree-ssa-coalesce.o,
tree-outof-ssa.o, tree-ssa-forwprop.o, tree-ssa-phiprop.o,
tree-ssa-ifcombine.o, tree-nrv.o, tree-ssa-copy.o,
tree-ssa-propagate.o, tree-ssa-dom.o, tree-ssa-uncprop.o,
tree-ssa-live.o, tree-ssa-copyrename.o, tree-ssa-pre.o,
tree-ssa-sccvn.o, tree-vrp.o, tree-cfg.o, tree-tailcall.o,
tree-ssa-sink.o, tree-if-conv.o, tree-dfa.o, tree-ssa-operands.o,
tree-ssa-address.o, tree-ssa-loop-niter.o,
tree-ssa-loop-ivcanon.o, tree-ssa-loop-prefetch.o, tree-predcom.o,
tree-ssa-loop-ivopts.o, tree-affine.o, tree-ssa-loop-im.o,
tree-ssa-math-opts.o, tree-ssa-alias.o, tree-ssa-reassoc.o,
gimplify.o, tree-browser.o, tree-chrec.o, tree-scalar-evolution.o,
tree-data-ref.o, sese.o, graphite-poly.o, tree-vect-loop.o,
tree-vect-loop-manip.o, tree-vect-patterns.o, tree-vect-slp.o,
tree-vect-stmts.o, tree-vect-data-refs.o, tree-vectorizer.o,
tree-parloops.o, tree-stdarg.o, tree-object-size.o,
gimple-pretty-print.o, tree-pretty-print.o, diagnostic.o,
toplev.o, print-rtl.o, except.o, dwarf2out.o, cgraphunit.o,
ipa-prop.o, ipa-cp.o, ipa-inline.o, ipa-pure-const.o,
ipa-type-escape.o, ipa-struct-reorg.o, tree-ssa-dce.o,
tree-call-cdce.o, tree-ssa-ccp.o, tree-sra.o,
tree-switch-conversion.o, var-tracking.o, value-prof.o,
cfgexpand.o, pretty-print.o): Update dependencies.
cp:
* error.c: Include tree-diagnostic.h and tree-pretty-print.h.
(cp_print_error_function): Use diagnostic_abstract_origin macro.
(cp_printer): Handle %K here using percent_K_format.
* cxx-pretty-print.c: Include tree-pretty-print.h.
* Make-lang.in (cp/error.o, cp/cxx-pretty-print.o): Update
dependencies.
From-SVN: r159685
2010-05-22 00:34:26 +02:00
|
|
|
#include "tree-pretty-print.h"
|
2007-01-28 14:01:53 +01:00
|
|
|
#include "tree-dump.h"
|
|
|
|
#include "tree-inline.h"
|
2008-08-24 22:09:32 +02:00
|
|
|
#include "fibheap.h"
|
|
|
|
#include "params.h"
|
cgraph.c (dump_cgraph_node): Do not dump inline summaries.
* cgraph.c (dump_cgraph_node): Do not dump inline summaries.
* cgraph.h (struct inline_summary): Move to ipa-inline.h
(cgraph_local_info): Remove inline_summary.
* ipa-cp.c: Include ipa-inline.h.
(ipcp_cloning_candidate_p, ipcp_estimate_growth,
ipcp_estimate_cloning_cost, ipcp_insert_stage): Use inline_summary
accesor.
* lto-cgraph.c (lto_output_node): Do not stream inline summary.
(input_overwrite_node): Do not set inline summary.
(input_node): Do not stream inline summary.
* ipa-inline.c (cgraph_decide_inlining): Dump inline summaries.
(cgraph_decide_inlining_incrementally): Do not try to estimate overall
growth; we do not have inline parameters computed for that anyway.
(cgraph_early_inlining): After inlining compute call_stmt_sizes.
* ipa-inline.h (struct inline_summary): Move here from ipa-inline.h
(inline_summary_t): New type and VECtor.
(debug_inline_summary, dump_inline_summaries): Declare.
(inline_summary): Use VOCtor.
(estimate_edge_growth): Kill hack computing call stmt size directly.
* lto-section-in.c (lto_section_name): Add inline section.
* ipa-inline-analysis.c: Include lto-streamer.h
(node_removal_hook_holder, node_duplication_hook_holder): New holders
(inline_node_removal_hook, inline_node_duplication_hook): New functions.
(inline_summary_vec): Define.
(inline_summary_alloc, dump_inline_summary, debug_inline_summary,
dump_inline_summaries): New functions.
(estimate_function_body_sizes): Properly compute size/time of outgoing calls.
(compute_inline_parameters): Alloc inline_summary; do not compute size/time
of incomming calls.
(estimate_edge_time): Avoid missing time summary hack.
(inline_read_summary): Read inline summary info.
(inline_write_summary): Write inline summary info.
(inline_free_summary): Free all hooks and inline summary vector.
* lto-streamer.h: Add LTO_section_inline_summary section.
* Makefile.in (ipa-cp.o, ipa-inline-analysis.o): Update dependencies.
* ipa.c (cgraph_remove_unreachable_nodes): Fix dump file formating.
* lto.c: Include ipa-inline.h
(add_cgraph_node_to_partition, undo_partition): Use inline_summary accessor.
(ipa_node_duplication_hook): Fix declaration.
* Make-lang.in (lto.o): Update dependencies.
From-SVN: r172430
2011-04-14 15:26:44 +02:00
|
|
|
#include "ipa-inline.h"
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
/* Number of functions identified as candidates for cloning. When not cloning
|
|
|
|
we can simplify iterate stage not forcing it to go through the decision
|
|
|
|
on what is profitable and what not. */
|
|
|
|
static int n_cloning_candidates;
|
|
|
|
|
|
|
|
/* Maximal count found in program. */
|
|
|
|
static gcov_type max_count;
|
|
|
|
|
|
|
|
/* Cgraph nodes that has been completely replaced by cloning during iterate
|
|
|
|
* stage and will be removed after ipcp is finished. */
|
|
|
|
static bitmap dead_nodes;
|
|
|
|
|
|
|
|
static void ipcp_print_profile_data (FILE *);
|
|
|
|
static void ipcp_function_scale_print (FILE *);
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Get the original node field of ipa_node_params associated with node NODE. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static inline struct cgraph_node *
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_get_orig_node (struct cgraph_node *node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
return IPA_NODE_REF (node)->ipcp_orig_node;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Return true if NODE describes a cloned/versioned function. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static inline bool
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_node_is_clone (struct cgraph_node *node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
return (ipcp_get_orig_node (node) != NULL);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Create ipa_node_params and its data structures for NEW_NODE. Set ORIG_NODE
|
|
|
|
as the ipcp_orig_node field in ipa_node_params. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_init_cloned_node (struct cgraph_node *orig_node,
|
|
|
|
struct cgraph_node *new_node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2010-06-28 18:43:09 +02:00
|
|
|
gcc_checking_assert (ipa_node_params_vector
|
|
|
|
&& (VEC_length (ipa_node_params_t,
|
|
|
|
ipa_node_params_vector)
|
|
|
|
> (unsigned) cgraph_max_uid));
|
|
|
|
gcc_checking_assert (IPA_NODE_REF (new_node)->params);
|
2008-05-06 16:15:18 +02:00
|
|
|
IPA_NODE_REF (new_node)->ipcp_orig_node = orig_node;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Return scale for NODE. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static inline gcov_type
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_get_node_scale (struct cgraph_node *node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
return IPA_NODE_REF (node)->count_scale;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Set COUNT as scale for NODE. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static inline void
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_set_node_scale (struct cgraph_node *node, gcov_type count)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
IPA_NODE_REF (node)->count_scale = count;
|
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Return whether LAT is a constant lattice. */
|
|
|
|
static inline bool
|
|
|
|
ipcp_lat_is_const (struct ipcp_lattice *lat)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-08-23 22:28:07 +02:00
|
|
|
if (lat->type == IPA_CONST_VALUE)
|
2005-08-01 09:26:30 +02:00
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-07-23 21:45:45 +02:00
|
|
|
/* Return whether LAT is a constant lattice that ipa-cp can actually insert
|
|
|
|
into the code (i.e. constants excluding member pointers and pointers). */
|
|
|
|
static inline bool
|
|
|
|
ipcp_lat_is_insertable (struct ipcp_lattice *lat)
|
|
|
|
{
|
2008-08-23 22:28:07 +02:00
|
|
|
return lat->type == IPA_CONST_VALUE;
|
2008-07-23 21:45:45 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Return true if LAT1 and LAT2 are equal. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static inline bool
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_lats_are_equal (struct ipcp_lattice *lat1, struct ipcp_lattice *lat2)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
gcc_assert (ipcp_lat_is_const (lat1) && ipcp_lat_is_const (lat2));
|
|
|
|
if (lat1->type != lat2->type)
|
2005-08-01 09:26:30 +02:00
|
|
|
return false;
|
|
|
|
|
2010-04-09 22:24:11 +02:00
|
|
|
if (TREE_CODE (lat1->constant) == ADDR_EXPR
|
|
|
|
&& TREE_CODE (lat2->constant) == ADDR_EXPR
|
|
|
|
&& TREE_CODE (TREE_OPERAND (lat1->constant, 0)) == CONST_DECL
|
|
|
|
&& TREE_CODE (TREE_OPERAND (lat2->constant, 0)) == CONST_DECL)
|
|
|
|
return operand_equal_p (DECL_INITIAL (TREE_OPERAND (lat1->constant, 0)),
|
|
|
|
DECL_INITIAL (TREE_OPERAND (lat2->constant, 0)), 0);
|
|
|
|
else
|
|
|
|
return operand_equal_p (lat1->constant, lat2->constant, 0);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Compute Meet arithmetics:
|
2008-04-30 12:01:59 +02:00
|
|
|
Meet (IPA_BOTTOM, x) = IPA_BOTTOM
|
|
|
|
Meet (IPA_TOP,x) = x
|
|
|
|
Meet (const_a,const_b) = IPA_BOTTOM, if const_a != const_b.
|
2005-08-01 09:26:30 +02:00
|
|
|
MEET (const_a,const_b) = const_a, if const_a == const_b.*/
|
|
|
|
static void
|
2008-05-06 16:15:18 +02:00
|
|
|
ipa_lattice_meet (struct ipcp_lattice *res, struct ipcp_lattice *lat1,
|
|
|
|
struct ipcp_lattice *lat2)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
if (lat1->type == IPA_BOTTOM || lat2->type == IPA_BOTTOM)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
res->type = IPA_BOTTOM;
|
2005-08-01 09:26:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-05-06 16:15:18 +02:00
|
|
|
if (lat1->type == IPA_TOP)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
res->type = lat2->type;
|
|
|
|
res->constant = lat2->constant;
|
2005-08-01 09:26:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-05-06 16:15:18 +02:00
|
|
|
if (lat2->type == IPA_TOP)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
res->type = lat1->type;
|
|
|
|
res->constant = lat1->constant;
|
2005-08-01 09:26:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-05-06 16:15:18 +02:00
|
|
|
if (!ipcp_lats_are_equal (lat1, lat2))
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
res->type = IPA_BOTTOM;
|
2005-08-01 09:26:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-05-06 16:15:18 +02:00
|
|
|
res->type = lat1->type;
|
|
|
|
res->constant = lat1->constant;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Return the lattice corresponding to the Ith formal parameter of the function
|
|
|
|
described by INFO. */
|
2008-04-30 12:01:59 +02:00
|
|
|
static inline struct ipcp_lattice *
|
ipa-prop.h (struct ipa_param_flags): Removed.
2008-09-11 Martin Jambor <mjambor@suse.cz>
* ipa-prop.h (struct ipa_param_flags): Removed.
(struct ipa_param_descriptor): New structure.
(struct ipa_node_params): ipcp_lattices, param_decls and
param_flags moved to ipa_param_description.
(ipa_get_ith_param): Renamed to ipa_get_param, changed to access
descriptors. Renamed all users.
(ipa_is_ith_param_modified): Renamed to ipa_is_param_modified,
changed to access descriptors. Renamed all users.
(ipa_is_ith_param_called): Renamed to ipa_is_param_called, changed
to access descriptors. Renamed all users.
* ipa-cp.c (ipcp_init_cloned_node): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
(ipcp_analyze_node): Likewise.
(ipcp_get_ith_lattice): Renamed to ipcp_get_lattice, changed to access
descriptors. Renamed all users.
(ipcp_initialize_node_lattices): Remove allocation.
* ipa-inline.c (inline_indirect_intraprocedural_analysis): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
* ipa-prop.c (ipa_create_param_decls_array): Renamed to
ipa_populate_param_decls, made static, added parameter info,
renamed mt to node, removed allocation, changed to use
descriptors.
(ipa_count_formal_params): Made static, added parameter info,
renamed mt to node.
(ipa_initialize_node_params): New function.
(ipa_check_stmt_modifications): Changed to use descriptors.
(ipa_detect_param_modifications): Removed allocation, changed to
use descriptors.
(ipa_note_param_call): Changed to use descriptors.
(ipa_analyze_params_uses): Removed allocation.
(ipa_free_node_params_substructures): Changed to use descriptors.
(ipa_edge_duplication_hook): Use the unused attribute.
(ipa_node_duplication_hook): Use the unused attribute, changed to
use descriptors, changed to duplicate descriptors.
* ipa-inline.c (cgraph_mark_inline_edge): New parameter new_edges,
changed all callers. Call ipa_propagate_indirect_call_infos if doing
indirect inlining. Made static.
(cgraph_decide_inlining): Freeing ipa-prop structures after inlining
functions called only once.
(cgraph_decide_recursive_inlining): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining_of_small_functions): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining): Don't call
ipa_propagate_indirect_call_infos.
* ipa-prop.c: Check that vectors are allocated.
* ipa-inline.c (cgraph_mark_inline_edge): Returns boolean, true
iff a new cgraph edges have been created.
(cgraph_decide_inlining): New variable redo_always_inline.
Flattening and always_inlining loop until callgraph stabilizes.
* ipa-prop.c (update_call_notes_after_inlining): Returns boolean,
true iff new cgraph edges have been created.
(propagate_info_to_inlined_callees): Likewise.
(ipa_propagate_indirect_call_infos): Likewise.
From-SVN: r140293
2008-09-11 19:03:23 +02:00
|
|
|
ipcp_get_lattice (struct ipa_node_params *info, int i)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
ipa-prop.h (struct ipa_param_flags): Removed.
2008-09-11 Martin Jambor <mjambor@suse.cz>
* ipa-prop.h (struct ipa_param_flags): Removed.
(struct ipa_param_descriptor): New structure.
(struct ipa_node_params): ipcp_lattices, param_decls and
param_flags moved to ipa_param_description.
(ipa_get_ith_param): Renamed to ipa_get_param, changed to access
descriptors. Renamed all users.
(ipa_is_ith_param_modified): Renamed to ipa_is_param_modified,
changed to access descriptors. Renamed all users.
(ipa_is_ith_param_called): Renamed to ipa_is_param_called, changed
to access descriptors. Renamed all users.
* ipa-cp.c (ipcp_init_cloned_node): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
(ipcp_analyze_node): Likewise.
(ipcp_get_ith_lattice): Renamed to ipcp_get_lattice, changed to access
descriptors. Renamed all users.
(ipcp_initialize_node_lattices): Remove allocation.
* ipa-inline.c (inline_indirect_intraprocedural_analysis): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
* ipa-prop.c (ipa_create_param_decls_array): Renamed to
ipa_populate_param_decls, made static, added parameter info,
renamed mt to node, removed allocation, changed to use
descriptors.
(ipa_count_formal_params): Made static, added parameter info,
renamed mt to node.
(ipa_initialize_node_params): New function.
(ipa_check_stmt_modifications): Changed to use descriptors.
(ipa_detect_param_modifications): Removed allocation, changed to
use descriptors.
(ipa_note_param_call): Changed to use descriptors.
(ipa_analyze_params_uses): Removed allocation.
(ipa_free_node_params_substructures): Changed to use descriptors.
(ipa_edge_duplication_hook): Use the unused attribute.
(ipa_node_duplication_hook): Use the unused attribute, changed to
use descriptors, changed to duplicate descriptors.
* ipa-inline.c (cgraph_mark_inline_edge): New parameter new_edges,
changed all callers. Call ipa_propagate_indirect_call_infos if doing
indirect inlining. Made static.
(cgraph_decide_inlining): Freeing ipa-prop structures after inlining
functions called only once.
(cgraph_decide_recursive_inlining): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining_of_small_functions): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining): Don't call
ipa_propagate_indirect_call_infos.
* ipa-prop.c: Check that vectors are allocated.
* ipa-inline.c (cgraph_mark_inline_edge): Returns boolean, true
iff a new cgraph edges have been created.
(cgraph_decide_inlining): New variable redo_always_inline.
Flattening and always_inlining loop until callgraph stabilizes.
* ipa-prop.c (update_call_notes_after_inlining): Returns boolean,
true iff new cgraph edges have been created.
(propagate_info_to_inlined_callees): Likewise.
(ipa_propagate_indirect_call_infos): Likewise.
From-SVN: r140293
2008-09-11 19:03:23 +02:00
|
|
|
return &(info->params[i].ipcp_lattice);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Given the jump function JFUNC, compute the lattice LAT that describes the
|
|
|
|
value coming down the callsite. INFO describes the caller node so that
|
|
|
|
pass-through jump functions can be evaluated. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_lattice_from_jfunc (struct ipa_node_params *info, struct ipcp_lattice *lat,
|
|
|
|
struct ipa_jump_func *jfunc)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2009-03-30 15:06:52 +02:00
|
|
|
if (jfunc->type == IPA_JF_CONST)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
lat->type = IPA_CONST_VALUE;
|
|
|
|
lat->constant = jfunc->value.constant;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2009-03-30 15:06:52 +02:00
|
|
|
else if (jfunc->type == IPA_JF_PASS_THROUGH)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
struct ipcp_lattice *caller_lat;
|
2009-08-07 09:15:41 +02:00
|
|
|
tree cst;
|
2008-05-06 16:15:18 +02:00
|
|
|
|
2009-08-07 09:15:41 +02:00
|
|
|
caller_lat = ipcp_get_lattice (info, jfunc->value.pass_through.formal_id);
|
2008-05-06 16:15:18 +02:00
|
|
|
lat->type = caller_lat->type;
|
2009-08-07 09:15:41 +02:00
|
|
|
if (caller_lat->type != IPA_CONST_VALUE)
|
|
|
|
return;
|
|
|
|
cst = caller_lat->constant;
|
|
|
|
|
|
|
|
if (jfunc->value.pass_through.operation != NOP_EXPR)
|
2009-10-13 13:31:08 +02:00
|
|
|
{
|
|
|
|
tree restype;
|
|
|
|
if (TREE_CODE_CLASS (jfunc->value.pass_through.operation)
|
|
|
|
== tcc_comparison)
|
|
|
|
restype = boolean_type_node;
|
|
|
|
else
|
|
|
|
restype = TREE_TYPE (cst);
|
|
|
|
cst = fold_binary (jfunc->value.pass_through.operation,
|
|
|
|
restype, cst, jfunc->value.pass_through.operand);
|
|
|
|
}
|
2009-08-12 19:55:40 +02:00
|
|
|
if (!cst || !is_gimple_ip_invariant (cst))
|
|
|
|
lat->type = IPA_BOTTOM;
|
2009-08-07 09:15:41 +02:00
|
|
|
lat->constant = cst;
|
|
|
|
}
|
|
|
|
else if (jfunc->type == IPA_JF_ANCESTOR)
|
|
|
|
{
|
|
|
|
struct ipcp_lattice *caller_lat;
|
|
|
|
tree t;
|
|
|
|
|
|
|
|
caller_lat = ipcp_get_lattice (info, jfunc->value.ancestor.formal_id);
|
|
|
|
lat->type = caller_lat->type;
|
|
|
|
if (caller_lat->type != IPA_CONST_VALUE)
|
|
|
|
return;
|
|
|
|
if (TREE_CODE (caller_lat->constant) != ADDR_EXPR)
|
|
|
|
{
|
|
|
|
/* This can happen when the constant is a NULL pointer. */
|
|
|
|
lat->type = IPA_BOTTOM;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
t = TREE_OPERAND (caller_lat->constant, 0);
|
2010-09-14 16:09:38 +02:00
|
|
|
t = build_ref_for_offset (EXPR_LOCATION (t), t,
|
|
|
|
jfunc->value.ancestor.offset,
|
2010-09-10 01:38:23 +02:00
|
|
|
jfunc->value.ancestor.type, NULL, false);
|
|
|
|
lat->constant = build_fold_addr_expr (t);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2008-07-23 21:45:45 +02:00
|
|
|
else
|
|
|
|
lat->type = IPA_BOTTOM;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
builtins.c (expand_builtin_profile_func): Avoid C++ keywords.
* builtins.c (expand_builtin_profile_func): Avoid C++ keywords.
* calls.c (avoid_likely_spilled_reg): Likewise.
* cfgexpand.c (gimple_assign_rhs_to_tree): Likewise.
* cgraph.c (cgraph_clone_edge, cgraph_clone_node): Likewise.
* config/i386/i386.c (ix86_expand_special_args_builtin,
ix86_secondary_reload): Likewise.
* except.c (struct eh_region, gen_eh_region_catch,
remove_unreachable_regions, duplicate_eh_regions,
assign_filter_values, build_post_landing_pads,
sjlj_find_directly_reachable_regions, remove_eh_handler,
reachable_next_level, foreach_reachable_handler,
can_throw_internal_1, can_throw_external_1,
collect_one_action_chain): Likewise.
* expr.c (expand_expr_real_1, vector_mode_valid_p): Likewise.
* fold-const.c (twoval_comparison_p, eval_subst): Likewise.
* function.c (update_temp_slot_address, instantiate_new_reg,
instantiate_virtual_regs_in_rtx,
instantiate_virtual_regs_in_insn): Likewise.
* gimple.c (extract_ops_from_tree, gimple_seq_copy): Likewise.
* gimplify.c (gimplify_call_expr, gimplify_init_constructor,
gimplify_cleanup_point_expr): Likewise.
* ipa-cp.c (ipcp_lattice_changed): Likewise.
* passes.c (next_pass_1): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* profile.c (branch_prob): Likewise.
* tree-dump.c (dump_register): Likewise.
* tree-eh.c (replace_goto_queue_cond_clause, lower_catch):
Likewise.
* tree-inline.c (remap_ssa_name, remap_type_1, remap_blocks,
copy_statement_list, remap_gimple_op_r, copy_tree_body_r,
copy_edges_for_bb, copy_cfg_body, copy_tree_r,
copy_arguments_for_versioning, copy_static_chain): Likewise.
* tree-into-ssa.c (names_replaced_by, add_to_repl_tbl,
add_new_name_mapping, register_new_name_mapping): Likewise.
* tree-mudflap.c (mf_xform_derefs): Likewise.
* tree-predcom.c (struct chain, dump_chain, replace_ref_with,
get_init_expr, combine_chains): Likewise.
* tree-pretty-print.c (dump_generic_node): Likewise.
* tree-ssa-structalias.c (create_variable_info_for): Likewise.
* tree-vrp.c (simplify_cond_using_ranges): Likewise.
* tree.c (substitute_in_expr, iterative_hash_expr): Likewise.
* value-prof.c (gimple_duplicate_stmt_histograms): Likewise.
From-SVN: r138809
2008-08-06 17:57:09 +02:00
|
|
|
/* True when OLD_LAT and NEW_LAT values are not the same. */
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static bool
|
builtins.c (expand_builtin_profile_func): Avoid C++ keywords.
* builtins.c (expand_builtin_profile_func): Avoid C++ keywords.
* calls.c (avoid_likely_spilled_reg): Likewise.
* cfgexpand.c (gimple_assign_rhs_to_tree): Likewise.
* cgraph.c (cgraph_clone_edge, cgraph_clone_node): Likewise.
* config/i386/i386.c (ix86_expand_special_args_builtin,
ix86_secondary_reload): Likewise.
* except.c (struct eh_region, gen_eh_region_catch,
remove_unreachable_regions, duplicate_eh_regions,
assign_filter_values, build_post_landing_pads,
sjlj_find_directly_reachable_regions, remove_eh_handler,
reachable_next_level, foreach_reachable_handler,
can_throw_internal_1, can_throw_external_1,
collect_one_action_chain): Likewise.
* expr.c (expand_expr_real_1, vector_mode_valid_p): Likewise.
* fold-const.c (twoval_comparison_p, eval_subst): Likewise.
* function.c (update_temp_slot_address, instantiate_new_reg,
instantiate_virtual_regs_in_rtx,
instantiate_virtual_regs_in_insn): Likewise.
* gimple.c (extract_ops_from_tree, gimple_seq_copy): Likewise.
* gimplify.c (gimplify_call_expr, gimplify_init_constructor,
gimplify_cleanup_point_expr): Likewise.
* ipa-cp.c (ipcp_lattice_changed): Likewise.
* passes.c (next_pass_1): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* profile.c (branch_prob): Likewise.
* tree-dump.c (dump_register): Likewise.
* tree-eh.c (replace_goto_queue_cond_clause, lower_catch):
Likewise.
* tree-inline.c (remap_ssa_name, remap_type_1, remap_blocks,
copy_statement_list, remap_gimple_op_r, copy_tree_body_r,
copy_edges_for_bb, copy_cfg_body, copy_tree_r,
copy_arguments_for_versioning, copy_static_chain): Likewise.
* tree-into-ssa.c (names_replaced_by, add_to_repl_tbl,
add_new_name_mapping, register_new_name_mapping): Likewise.
* tree-mudflap.c (mf_xform_derefs): Likewise.
* tree-predcom.c (struct chain, dump_chain, replace_ref_with,
get_init_expr, combine_chains): Likewise.
* tree-pretty-print.c (dump_generic_node): Likewise.
* tree-ssa-structalias.c (create_variable_info_for): Likewise.
* tree-vrp.c (simplify_cond_using_ranges): Likewise.
* tree.c (substitute_in_expr, iterative_hash_expr): Likewise.
* value-prof.c (gimple_duplicate_stmt_histograms): Likewise.
From-SVN: r138809
2008-08-06 17:57:09 +02:00
|
|
|
ipcp_lattice_changed (struct ipcp_lattice *old_lat,
|
|
|
|
struct ipcp_lattice *new_lat)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
builtins.c (expand_builtin_profile_func): Avoid C++ keywords.
* builtins.c (expand_builtin_profile_func): Avoid C++ keywords.
* calls.c (avoid_likely_spilled_reg): Likewise.
* cfgexpand.c (gimple_assign_rhs_to_tree): Likewise.
* cgraph.c (cgraph_clone_edge, cgraph_clone_node): Likewise.
* config/i386/i386.c (ix86_expand_special_args_builtin,
ix86_secondary_reload): Likewise.
* except.c (struct eh_region, gen_eh_region_catch,
remove_unreachable_regions, duplicate_eh_regions,
assign_filter_values, build_post_landing_pads,
sjlj_find_directly_reachable_regions, remove_eh_handler,
reachable_next_level, foreach_reachable_handler,
can_throw_internal_1, can_throw_external_1,
collect_one_action_chain): Likewise.
* expr.c (expand_expr_real_1, vector_mode_valid_p): Likewise.
* fold-const.c (twoval_comparison_p, eval_subst): Likewise.
* function.c (update_temp_slot_address, instantiate_new_reg,
instantiate_virtual_regs_in_rtx,
instantiate_virtual_regs_in_insn): Likewise.
* gimple.c (extract_ops_from_tree, gimple_seq_copy): Likewise.
* gimplify.c (gimplify_call_expr, gimplify_init_constructor,
gimplify_cleanup_point_expr): Likewise.
* ipa-cp.c (ipcp_lattice_changed): Likewise.
* passes.c (next_pass_1): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* profile.c (branch_prob): Likewise.
* tree-dump.c (dump_register): Likewise.
* tree-eh.c (replace_goto_queue_cond_clause, lower_catch):
Likewise.
* tree-inline.c (remap_ssa_name, remap_type_1, remap_blocks,
copy_statement_list, remap_gimple_op_r, copy_tree_body_r,
copy_edges_for_bb, copy_cfg_body, copy_tree_r,
copy_arguments_for_versioning, copy_static_chain): Likewise.
* tree-into-ssa.c (names_replaced_by, add_to_repl_tbl,
add_new_name_mapping, register_new_name_mapping): Likewise.
* tree-mudflap.c (mf_xform_derefs): Likewise.
* tree-predcom.c (struct chain, dump_chain, replace_ref_with,
get_init_expr, combine_chains): Likewise.
* tree-pretty-print.c (dump_generic_node): Likewise.
* tree-ssa-structalias.c (create_variable_info_for): Likewise.
* tree-vrp.c (simplify_cond_using_ranges): Likewise.
* tree.c (substitute_in_expr, iterative_hash_expr): Likewise.
* value-prof.c (gimple_duplicate_stmt_histograms): Likewise.
From-SVN: r138809
2008-08-06 17:57:09 +02:00
|
|
|
if (old_lat->type == new_lat->type)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
builtins.c (expand_builtin_profile_func): Avoid C++ keywords.
* builtins.c (expand_builtin_profile_func): Avoid C++ keywords.
* calls.c (avoid_likely_spilled_reg): Likewise.
* cfgexpand.c (gimple_assign_rhs_to_tree): Likewise.
* cgraph.c (cgraph_clone_edge, cgraph_clone_node): Likewise.
* config/i386/i386.c (ix86_expand_special_args_builtin,
ix86_secondary_reload): Likewise.
* except.c (struct eh_region, gen_eh_region_catch,
remove_unreachable_regions, duplicate_eh_regions,
assign_filter_values, build_post_landing_pads,
sjlj_find_directly_reachable_regions, remove_eh_handler,
reachable_next_level, foreach_reachable_handler,
can_throw_internal_1, can_throw_external_1,
collect_one_action_chain): Likewise.
* expr.c (expand_expr_real_1, vector_mode_valid_p): Likewise.
* fold-const.c (twoval_comparison_p, eval_subst): Likewise.
* function.c (update_temp_slot_address, instantiate_new_reg,
instantiate_virtual_regs_in_rtx,
instantiate_virtual_regs_in_insn): Likewise.
* gimple.c (extract_ops_from_tree, gimple_seq_copy): Likewise.
* gimplify.c (gimplify_call_expr, gimplify_init_constructor,
gimplify_cleanup_point_expr): Likewise.
* ipa-cp.c (ipcp_lattice_changed): Likewise.
* passes.c (next_pass_1): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* profile.c (branch_prob): Likewise.
* tree-dump.c (dump_register): Likewise.
* tree-eh.c (replace_goto_queue_cond_clause, lower_catch):
Likewise.
* tree-inline.c (remap_ssa_name, remap_type_1, remap_blocks,
copy_statement_list, remap_gimple_op_r, copy_tree_body_r,
copy_edges_for_bb, copy_cfg_body, copy_tree_r,
copy_arguments_for_versioning, copy_static_chain): Likewise.
* tree-into-ssa.c (names_replaced_by, add_to_repl_tbl,
add_new_name_mapping, register_new_name_mapping): Likewise.
* tree-mudflap.c (mf_xform_derefs): Likewise.
* tree-predcom.c (struct chain, dump_chain, replace_ref_with,
get_init_expr, combine_chains): Likewise.
* tree-pretty-print.c (dump_generic_node): Likewise.
* tree-ssa-structalias.c (create_variable_info_for): Likewise.
* tree-vrp.c (simplify_cond_using_ranges): Likewise.
* tree.c (substitute_in_expr, iterative_hash_expr): Likewise.
* value-prof.c (gimple_duplicate_stmt_histograms): Likewise.
From-SVN: r138809
2008-08-06 17:57:09 +02:00
|
|
|
if (!ipcp_lat_is_const (old_lat))
|
2005-08-01 09:26:30 +02:00
|
|
|
return false;
|
builtins.c (expand_builtin_profile_func): Avoid C++ keywords.
* builtins.c (expand_builtin_profile_func): Avoid C++ keywords.
* calls.c (avoid_likely_spilled_reg): Likewise.
* cfgexpand.c (gimple_assign_rhs_to_tree): Likewise.
* cgraph.c (cgraph_clone_edge, cgraph_clone_node): Likewise.
* config/i386/i386.c (ix86_expand_special_args_builtin,
ix86_secondary_reload): Likewise.
* except.c (struct eh_region, gen_eh_region_catch,
remove_unreachable_regions, duplicate_eh_regions,
assign_filter_values, build_post_landing_pads,
sjlj_find_directly_reachable_regions, remove_eh_handler,
reachable_next_level, foreach_reachable_handler,
can_throw_internal_1, can_throw_external_1,
collect_one_action_chain): Likewise.
* expr.c (expand_expr_real_1, vector_mode_valid_p): Likewise.
* fold-const.c (twoval_comparison_p, eval_subst): Likewise.
* function.c (update_temp_slot_address, instantiate_new_reg,
instantiate_virtual_regs_in_rtx,
instantiate_virtual_regs_in_insn): Likewise.
* gimple.c (extract_ops_from_tree, gimple_seq_copy): Likewise.
* gimplify.c (gimplify_call_expr, gimplify_init_constructor,
gimplify_cleanup_point_expr): Likewise.
* ipa-cp.c (ipcp_lattice_changed): Likewise.
* passes.c (next_pass_1): Likewise.
* print-tree.c (print_node_brief, print_node): Likewise.
* profile.c (branch_prob): Likewise.
* tree-dump.c (dump_register): Likewise.
* tree-eh.c (replace_goto_queue_cond_clause, lower_catch):
Likewise.
* tree-inline.c (remap_ssa_name, remap_type_1, remap_blocks,
copy_statement_list, remap_gimple_op_r, copy_tree_body_r,
copy_edges_for_bb, copy_cfg_body, copy_tree_r,
copy_arguments_for_versioning, copy_static_chain): Likewise.
* tree-into-ssa.c (names_replaced_by, add_to_repl_tbl,
add_new_name_mapping, register_new_name_mapping): Likewise.
* tree-mudflap.c (mf_xform_derefs): Likewise.
* tree-predcom.c (struct chain, dump_chain, replace_ref_with,
get_init_expr, combine_chains): Likewise.
* tree-pretty-print.c (dump_generic_node): Likewise.
* tree-ssa-structalias.c (create_variable_info_for): Likewise.
* tree-vrp.c (simplify_cond_using_ranges): Likewise.
* tree.c (substitute_in_expr, iterative_hash_expr): Likewise.
* value-prof.c (gimple_duplicate_stmt_histograms): Likewise.
From-SVN: r138809
2008-08-06 17:57:09 +02:00
|
|
|
if (ipcp_lats_are_equal (old_lat, new_lat))
|
2005-08-01 09:26:30 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Print all ipcp_lattices of all functions to F. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_print_all_lattices (FILE * f)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
struct cgraph_node *node;
|
|
|
|
int i, count;
|
2007-01-28 14:01:53 +01:00
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
fprintf (f, "\nLattice:\n");
|
2005-08-01 09:26:30 +02:00
|
|
|
for (node = cgraph_nodes; node; node = node->next)
|
|
|
|
{
|
2008-07-17 15:23:32 +02:00
|
|
|
struct ipa_node_params *info;
|
|
|
|
|
|
|
|
if (!node->analyzed)
|
|
|
|
continue;
|
|
|
|
info = IPA_NODE_REF (node);
|
2008-08-29 18:41:35 +02:00
|
|
|
fprintf (f, " Node: %s:\n", cgraph_node_name (node));
|
2008-05-06 16:15:18 +02:00
|
|
|
count = ipa_get_param_count (info);
|
2005-08-01 09:26:30 +02:00
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
ipa-prop.h (struct ipa_param_flags): Removed.
2008-09-11 Martin Jambor <mjambor@suse.cz>
* ipa-prop.h (struct ipa_param_flags): Removed.
(struct ipa_param_descriptor): New structure.
(struct ipa_node_params): ipcp_lattices, param_decls and
param_flags moved to ipa_param_description.
(ipa_get_ith_param): Renamed to ipa_get_param, changed to access
descriptors. Renamed all users.
(ipa_is_ith_param_modified): Renamed to ipa_is_param_modified,
changed to access descriptors. Renamed all users.
(ipa_is_ith_param_called): Renamed to ipa_is_param_called, changed
to access descriptors. Renamed all users.
* ipa-cp.c (ipcp_init_cloned_node): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
(ipcp_analyze_node): Likewise.
(ipcp_get_ith_lattice): Renamed to ipcp_get_lattice, changed to access
descriptors. Renamed all users.
(ipcp_initialize_node_lattices): Remove allocation.
* ipa-inline.c (inline_indirect_intraprocedural_analysis): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
* ipa-prop.c (ipa_create_param_decls_array): Renamed to
ipa_populate_param_decls, made static, added parameter info,
renamed mt to node, removed allocation, changed to use
descriptors.
(ipa_count_formal_params): Made static, added parameter info,
renamed mt to node.
(ipa_initialize_node_params): New function.
(ipa_check_stmt_modifications): Changed to use descriptors.
(ipa_detect_param_modifications): Removed allocation, changed to
use descriptors.
(ipa_note_param_call): Changed to use descriptors.
(ipa_analyze_params_uses): Removed allocation.
(ipa_free_node_params_substructures): Changed to use descriptors.
(ipa_edge_duplication_hook): Use the unused attribute.
(ipa_node_duplication_hook): Use the unused attribute, changed to
use descriptors, changed to duplicate descriptors.
* ipa-inline.c (cgraph_mark_inline_edge): New parameter new_edges,
changed all callers. Call ipa_propagate_indirect_call_infos if doing
indirect inlining. Made static.
(cgraph_decide_inlining): Freeing ipa-prop structures after inlining
functions called only once.
(cgraph_decide_recursive_inlining): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining_of_small_functions): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining): Don't call
ipa_propagate_indirect_call_infos.
* ipa-prop.c: Check that vectors are allocated.
* ipa-inline.c (cgraph_mark_inline_edge): Returns boolean, true
iff a new cgraph edges have been created.
(cgraph_decide_inlining): New variable redo_always_inline.
Flattening and always_inlining loop until callgraph stabilizes.
* ipa-prop.c (update_call_notes_after_inlining): Returns boolean,
true iff new cgraph edges have been created.
(propagate_info_to_inlined_callees): Likewise.
(ipa_propagate_indirect_call_infos): Likewise.
From-SVN: r140293
2008-09-11 19:03:23 +02:00
|
|
|
struct ipcp_lattice *lat = ipcp_get_lattice (info, i);
|
2008-07-23 21:45:45 +02:00
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
fprintf (f, " param [%d]: ", i);
|
2008-08-23 22:28:07 +02:00
|
|
|
if (lat->type == IPA_CONST_VALUE)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2010-04-09 22:24:11 +02:00
|
|
|
tree cst = lat->constant;
|
2005-08-01 09:26:30 +02:00
|
|
|
fprintf (f, "type is CONST ");
|
2010-04-09 22:24:11 +02:00
|
|
|
print_generic_expr (f, cst, 0);
|
|
|
|
if (TREE_CODE (cst) == ADDR_EXPR
|
|
|
|
&& TREE_CODE (TREE_OPERAND (cst, 0)) == CONST_DECL)
|
|
|
|
{
|
|
|
|
fprintf (f, " -> ");
|
|
|
|
print_generic_expr (f, DECL_INITIAL (TREE_OPERAND (cst, 0)),
|
|
|
|
0);
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2008-05-06 16:15:18 +02:00
|
|
|
else if (lat->type == IPA_TOP)
|
2010-08-05 15:23:07 +02:00
|
|
|
fprintf (f, "type is TOP");
|
|
|
|
else
|
|
|
|
fprintf (f, "type is BOTTOM");
|
|
|
|
if (ipa_param_cannot_devirtualize_p (info, i))
|
|
|
|
fprintf (f, " - cannot_devirtualize set\n");
|
|
|
|
else if (ipa_param_types_vec_empty (info, i))
|
|
|
|
fprintf (f, " - type list empty\n");
|
2005-08-01 09:26:30 +02:00
|
|
|
else
|
2010-08-05 15:23:07 +02:00
|
|
|
fprintf (f, "\n");
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-26 20:23:32 +02:00
|
|
|
/* Return true if ipcp algorithms would allow cloning NODE. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
ipcp_versionable_function_p (struct cgraph_node *node)
|
|
|
|
{
|
2010-05-17 09:01:26 +02:00
|
|
|
struct cgraph_edge *edge;
|
2009-06-26 20:23:32 +02:00
|
|
|
|
2010-09-07 19:00:44 +02:00
|
|
|
/* There are a number of generic reasons functions cannot be versioned. We
|
|
|
|
also cannot remove parameters if there are type attributes such as fnspec
|
|
|
|
present. */
|
cgraphbuild.c: Include ipa-inline.h.
* cgraphbuild.c: Include ipa-inline.h.
(reset_inline_failed): Use initialize_inline_failed.
* cgraph.c: Include ipa-inline.h.
(cgraph_create_node_1): Do not initialize estimated_growth.
(initialize_inline_failed): More to ipa-inline-analysis.c
(dump_cgraph_node): Do not dump inline flags.
* cgraph.h (cgraph_local_info): Remove inlineable, versionable
and disregard_inline_limits flags.
(cgrpah_global_info): Remove estimated_stack_size, stack_frame_offset,
time, size, estimated_growth.
* ipa-cp.c (ipcp_versionable_function_p, ipcp_generate_summary): Update.
* cgraphunit.c (cgraph_decide_is_function_needed): Use
DECL_DISREGARD_INLINE_LIMITS.
(cgraph_analyze_function): Do not initialize
node->local.disregard_inline_limits.
* lto-cgraph.c (lto_output_node, input_overwrite_node): Do not stream
inlinable, versionable and disregard_inline_limits.
* ipa-inline.c (cgraph_clone_inlined_nodes, cgraph_mark_inline_edge,
cgraph_check_inline_limits, cgraph_default_inline_p, cgraph_edge_badness,
update_caller_keys, update_callee_keys, add_new_edges_to_heap): Update.
(cgraph_decide_inlining_of_small_function): Update; set CIF_FUNCTION_NOT_INLINABLE
for uninlinable functions.
(cgraph_decide_inlining, cgraph_edge_early_inlinable_p,
cgraph_decide_inlining_incrementally): Update.
* ipa-inline.h (inline_summary): Add inlinable, versionable, disregard_inline_limits,
estimated_stack_size, stack_frame_offset, time, size and estimated_growth
parameters.
(estimate_edge_growth): Update.
(initialize_inline_failed): Declare.
* ipa-split.c: Include ipa-inline.h
(execute_split_functions): Update.
* ipa.c (cgraph_postorder): Use DECL_DISREGARD_INLINE_LIMITS.
(cgraph_remove_unreachable_nodes): Do not clear inlinable flag.
(record_cdtor_fn): Use DECL_DISREGARD_INLINE_LIMITS.
* ipa-inline-analysis.c (inline_node_removal_hook): Update; set
estimated_growth to INT_MIN.
(inline_node_duplication_hook): Likewise.
(dump_inline_summary): Dump new fields.
(compute_inline_parameters): Update.
(estimate_edge_time, estimate_time_after_inlining,
estimate_size_after_inlining, estimate_growth, inline_read_summary,
inline_write_summary):
(initialize_inline_failed): Move here from cgraph.c.
* tree-sra.c: Include ipa-inline.h.
(ipa_sra_preliminary_function_checks): Update.
* lto/lto.c (lto_balanced_map): Update.
Update.
* Makefile.in: (cgraph.o, cgraphbuild.o): Add dependency on
ipa-inline.h
From-SVN: r172581
2011-04-16 11:13:08 +02:00
|
|
|
if (!inline_summary (node)->versionable
|
2010-09-07 19:00:44 +02:00
|
|
|
|| TYPE_ATTRIBUTES (TREE_TYPE (node->decl)))
|
2009-06-26 20:23:32 +02:00
|
|
|
return false;
|
|
|
|
|
2010-05-17 09:01:26 +02:00
|
|
|
/* Removing arguments doesn't work if the function takes varargs
|
|
|
|
or use __builtin_apply_args. */
|
|
|
|
for (edge = node->callees; edge; edge = edge->next_callee)
|
2009-06-26 20:23:32 +02:00
|
|
|
{
|
2010-05-17 09:01:26 +02:00
|
|
|
tree t = edge->callee->decl;
|
|
|
|
if (DECL_BUILT_IN_CLASS (t) == BUILT_IN_NORMAL
|
|
|
|
&& (DECL_FUNCTION_CODE (t) == BUILT_IN_APPLY_ARGS
|
|
|
|
|| DECL_FUNCTION_CODE (t) == BUILT_IN_VA_START))
|
|
|
|
return false;
|
2009-06-26 20:23:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
/* Return true if this NODE is viable candidate for cloning. */
|
|
|
|
static bool
|
|
|
|
ipcp_cloning_candidate_p (struct cgraph_node *node)
|
|
|
|
{
|
|
|
|
int n_calls = 0;
|
|
|
|
int n_hot_calls = 0;
|
|
|
|
gcov_type direct_call_sum = 0;
|
|
|
|
struct cgraph_edge *e;
|
|
|
|
|
|
|
|
/* We never clone functions that are not visible from outside.
|
|
|
|
FIXME: in future we should clone such functions when they are called with
|
|
|
|
different constants, but current ipcp implementation is not good on this.
|
|
|
|
*/
|
2009-10-07 11:01:16 +02:00
|
|
|
if (cgraph_only_called_directly_p (node) || !node->analyzed)
|
2008-08-29 18:41:35 +02:00
|
|
|
return false;
|
|
|
|
|
2010-10-26 18:40:16 +02:00
|
|
|
/* When function address is taken, we are pretty sure it will be called in hidden way. */
|
|
|
|
if (node->address_taken)
|
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Not considering %s for cloning; address is taken.\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
if (cgraph_function_body_availability (node) <= AVAIL_OVERWRITABLE)
|
|
|
|
{
|
|
|
|
if (dump_file)
|
2011-02-11 16:16:46 +01:00
|
|
|
fprintf (dump_file, "Not considering %s for cloning; body is overwritable.\n",
|
2008-08-29 18:41:35 +02:00
|
|
|
cgraph_node_name (node));
|
|
|
|
return false;
|
|
|
|
}
|
2009-06-26 20:23:32 +02:00
|
|
|
if (!ipcp_versionable_function_p (node))
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Not considering %s for cloning; body is not versionable.\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
for (e = node->callers; e; e = e->next_caller)
|
|
|
|
{
|
|
|
|
direct_call_sum += e->count;
|
|
|
|
n_calls ++;
|
|
|
|
if (cgraph_maybe_hot_edge_p (e))
|
|
|
|
n_hot_calls ++;
|
|
|
|
}
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
if (!n_calls)
|
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Not considering %s for cloning; no direct calls.\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
return false;
|
|
|
|
}
|
cgraph.c (dump_cgraph_node): Do not dump inline summaries.
* cgraph.c (dump_cgraph_node): Do not dump inline summaries.
* cgraph.h (struct inline_summary): Move to ipa-inline.h
(cgraph_local_info): Remove inline_summary.
* ipa-cp.c: Include ipa-inline.h.
(ipcp_cloning_candidate_p, ipcp_estimate_growth,
ipcp_estimate_cloning_cost, ipcp_insert_stage): Use inline_summary
accesor.
* lto-cgraph.c (lto_output_node): Do not stream inline summary.
(input_overwrite_node): Do not set inline summary.
(input_node): Do not stream inline summary.
* ipa-inline.c (cgraph_decide_inlining): Dump inline summaries.
(cgraph_decide_inlining_incrementally): Do not try to estimate overall
growth; we do not have inline parameters computed for that anyway.
(cgraph_early_inlining): After inlining compute call_stmt_sizes.
* ipa-inline.h (struct inline_summary): Move here from ipa-inline.h
(inline_summary_t): New type and VECtor.
(debug_inline_summary, dump_inline_summaries): Declare.
(inline_summary): Use VOCtor.
(estimate_edge_growth): Kill hack computing call stmt size directly.
* lto-section-in.c (lto_section_name): Add inline section.
* ipa-inline-analysis.c: Include lto-streamer.h
(node_removal_hook_holder, node_duplication_hook_holder): New holders
(inline_node_removal_hook, inline_node_duplication_hook): New functions.
(inline_summary_vec): Define.
(inline_summary_alloc, dump_inline_summary, debug_inline_summary,
dump_inline_summaries): New functions.
(estimate_function_body_sizes): Properly compute size/time of outgoing calls.
(compute_inline_parameters): Alloc inline_summary; do not compute size/time
of incomming calls.
(estimate_edge_time): Avoid missing time summary hack.
(inline_read_summary): Read inline summary info.
(inline_write_summary): Write inline summary info.
(inline_free_summary): Free all hooks and inline summary vector.
* lto-streamer.h: Add LTO_section_inline_summary section.
* Makefile.in (ipa-cp.o, ipa-inline-analysis.o): Update dependencies.
* ipa.c (cgraph_remove_unreachable_nodes): Fix dump file formating.
* lto.c: Include ipa-inline.h
(add_cgraph_node_to_partition, undo_partition): Use inline_summary accessor.
(ipa_node_duplication_hook): Fix declaration.
* Make-lang.in (lto.o): Update dependencies.
From-SVN: r172430
2011-04-14 15:26:44 +02:00
|
|
|
if (inline_summary (node)->self_size < n_calls)
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Considering %s for cloning; code would shrink.\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
return true;
|
2009-11-25 11:55:54 +01:00
|
|
|
}
|
2008-08-29 18:41:35 +02:00
|
|
|
|
|
|
|
if (!flag_ipa_cp_clone)
|
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Not considering %s for cloning; -fipa-cp-clone disabled.\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!optimize_function_for_speed_p (DECL_STRUCT_FUNCTION (node->decl)))
|
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Not considering %s for cloning; optimizing it for size.\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* When profile is available and function is hot, propagate into it even if
|
|
|
|
calls seems cold; constant propagation can improve function's speed
|
2011-02-11 16:16:46 +01:00
|
|
|
significantly. */
|
2008-08-29 18:41:35 +02:00
|
|
|
if (max_count)
|
|
|
|
{
|
|
|
|
if (direct_call_sum > node->count * 90 / 100)
|
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Considering %s for cloning; usually called directly.\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!n_hot_calls)
|
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Not considering %s for cloning; no hot calls.\n",
|
|
|
|
cgraph_node_name (node));
|
2009-05-11 22:58:08 +02:00
|
|
|
return false;
|
2008-08-29 18:41:35 +02:00
|
|
|
}
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Considering %s for cloning.\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-05 15:23:07 +02:00
|
|
|
/* Mark parameter with index I of function described by INFO as unsuitable for
|
|
|
|
devirtualization. Return true if it has already been marked so. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
ipa_set_param_cannot_devirtualize (struct ipa_node_params *info, int i)
|
|
|
|
{
|
|
|
|
bool ret = info->params[i].cannot_devirtualize;
|
|
|
|
info->params[i].cannot_devirtualize = true;
|
|
|
|
if (info->params[i].types)
|
|
|
|
VEC_free (tree, heap, info->params[i].types);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Initialize ipcp_lattices array. The lattices corresponding to supported
|
|
|
|
types (integers, real types and Fortran constants defined as const_decls)
|
|
|
|
are initialized to IPA_TOP, the rest of them to IPA_BOTTOM. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_initialize_node_lattices (struct cgraph_node *node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
int i;
|
2008-05-06 16:15:18 +02:00
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
2008-08-29 18:41:35 +02:00
|
|
|
enum ipa_lattice_type type;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
if (ipa_is_called_with_var_arguments (info))
|
|
|
|
type = IPA_BOTTOM;
|
2010-10-26 18:40:16 +02:00
|
|
|
else if (node->local.local)
|
2008-08-29 18:41:35 +02:00
|
|
|
type = IPA_TOP;
|
2008-08-24 22:09:32 +02:00
|
|
|
/* When cloning is allowed, we can assume that externally visible functions
|
|
|
|
are not called. We will compensate this by cloning later. */
|
2008-08-29 18:41:35 +02:00
|
|
|
else if (ipcp_cloning_candidate_p (node))
|
|
|
|
type = IPA_TOP, n_cloning_candidates ++;
|
2008-08-24 22:09:32 +02:00
|
|
|
else
|
2008-08-29 18:41:35 +02:00
|
|
|
type = IPA_BOTTOM;
|
|
|
|
|
|
|
|
for (i = 0; i < ipa_get_param_count (info) ; i++)
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
|
|
|
ipcp_get_lattice (info, i)->type = type;
|
|
|
|
if (type == IPA_BOTTOM)
|
|
|
|
ipa_set_param_cannot_devirtualize (info, i);
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-03-05 00:07:20 +01:00
|
|
|
/* Build a constant tree with type TREE_TYPE and value according to LAT.
|
|
|
|
Return the tree, or, if it is not possible to convert such value
|
|
|
|
to TREE_TYPE, NULL. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static tree
|
2008-05-06 16:15:18 +02:00
|
|
|
build_const_val (struct ipcp_lattice *lat, tree tree_type)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-08-21 17:26:59 +02:00
|
|
|
tree val;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
gcc_assert (ipcp_lat_is_const (lat));
|
2008-08-21 17:26:59 +02:00
|
|
|
val = lat->constant;
|
|
|
|
|
|
|
|
if (!useless_type_conversion_p (tree_type, TREE_TYPE (val)))
|
|
|
|
{
|
|
|
|
if (fold_convertible_p (tree_type, val))
|
|
|
|
return fold_build1 (NOP_EXPR, tree_type, val);
|
2011-03-05 00:07:20 +01:00
|
|
|
else if (TYPE_SIZE (tree_type) == TYPE_SIZE (TREE_TYPE (val)))
|
2008-08-21 17:26:59 +02:00
|
|
|
return fold_build1 (VIEW_CONVERT_EXPR, tree_type, val);
|
2011-03-05 00:07:20 +01:00
|
|
|
else
|
|
|
|
return NULL;
|
2008-08-21 17:26:59 +02:00
|
|
|
}
|
|
|
|
return val;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Compute the proper scale for NODE. It is the ratio between the number of
|
|
|
|
direct calls (represented on the incoming cgraph_edges) and sum of all
|
2009-11-23 21:01:29 +01:00
|
|
|
invocations of NODE (represented as count in cgraph_node).
|
|
|
|
|
|
|
|
FIXME: This code is wrong. Since the callers can be also clones and
|
|
|
|
the clones are not scaled yet, the sums gets unrealistically high.
|
|
|
|
To properly compute the counts, we would need to do propagation across
|
2011-02-11 16:16:46 +01:00
|
|
|
callgraph (as external call to A might imply call to non-cloned B
|
|
|
|
if A's clone calls cloned B). */
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_compute_node_scale (struct cgraph_node *node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
gcov_type sum;
|
|
|
|
struct cgraph_edge *cs;
|
|
|
|
|
|
|
|
sum = 0;
|
|
|
|
/* Compute sum of all counts of callers. */
|
|
|
|
for (cs = node->callers; cs != NULL; cs = cs->next_caller)
|
|
|
|
sum += cs->count;
|
2009-11-23 21:01:29 +01:00
|
|
|
/* Work around the unrealistically high sum problem. We just don't want
|
|
|
|
the non-cloned body to have negative or very low frequency. Since
|
|
|
|
majority of execution time will be spent in clones anyway, this should
|
|
|
|
give good enough profile. */
|
|
|
|
if (sum > node->count * 9 / 10)
|
|
|
|
sum = node->count * 9 / 10;
|
2005-08-01 09:26:30 +02:00
|
|
|
if (node->count == 0)
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_set_node_scale (node, 0);
|
2005-08-01 09:26:30 +02:00
|
|
|
else
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_set_node_scale (node, sum * REG_BR_PROB_BASE / node->count);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Return true if there are some formal parameters whose value is IPA_TOP (in
|
|
|
|
the whole compilation unit). Change their values to IPA_BOTTOM, since they
|
|
|
|
most probably get their values from outside of this compilation unit. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static bool
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_change_tops_to_bottom (void)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
int i, count;
|
|
|
|
struct cgraph_node *node;
|
|
|
|
bool prop_again;
|
|
|
|
|
|
|
|
prop_again = false;
|
|
|
|
for (node = cgraph_nodes; node; node = node->next)
|
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
|
|
|
count = ipa_get_param_count (info);
|
2005-08-01 09:26:30 +02:00
|
|
|
for (i = 0; i < count; i++)
|
2008-05-06 16:15:18 +02:00
|
|
|
{
|
ipa-prop.h (struct ipa_param_flags): Removed.
2008-09-11 Martin Jambor <mjambor@suse.cz>
* ipa-prop.h (struct ipa_param_flags): Removed.
(struct ipa_param_descriptor): New structure.
(struct ipa_node_params): ipcp_lattices, param_decls and
param_flags moved to ipa_param_description.
(ipa_get_ith_param): Renamed to ipa_get_param, changed to access
descriptors. Renamed all users.
(ipa_is_ith_param_modified): Renamed to ipa_is_param_modified,
changed to access descriptors. Renamed all users.
(ipa_is_ith_param_called): Renamed to ipa_is_param_called, changed
to access descriptors. Renamed all users.
* ipa-cp.c (ipcp_init_cloned_node): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
(ipcp_analyze_node): Likewise.
(ipcp_get_ith_lattice): Renamed to ipcp_get_lattice, changed to access
descriptors. Renamed all users.
(ipcp_initialize_node_lattices): Remove allocation.
* ipa-inline.c (inline_indirect_intraprocedural_analysis): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
* ipa-prop.c (ipa_create_param_decls_array): Renamed to
ipa_populate_param_decls, made static, added parameter info,
renamed mt to node, removed allocation, changed to use
descriptors.
(ipa_count_formal_params): Made static, added parameter info,
renamed mt to node.
(ipa_initialize_node_params): New function.
(ipa_check_stmt_modifications): Changed to use descriptors.
(ipa_detect_param_modifications): Removed allocation, changed to
use descriptors.
(ipa_note_param_call): Changed to use descriptors.
(ipa_analyze_params_uses): Removed allocation.
(ipa_free_node_params_substructures): Changed to use descriptors.
(ipa_edge_duplication_hook): Use the unused attribute.
(ipa_node_duplication_hook): Use the unused attribute, changed to
use descriptors, changed to duplicate descriptors.
* ipa-inline.c (cgraph_mark_inline_edge): New parameter new_edges,
changed all callers. Call ipa_propagate_indirect_call_infos if doing
indirect inlining. Made static.
(cgraph_decide_inlining): Freeing ipa-prop structures after inlining
functions called only once.
(cgraph_decide_recursive_inlining): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining_of_small_functions): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining): Don't call
ipa_propagate_indirect_call_infos.
* ipa-prop.c: Check that vectors are allocated.
* ipa-inline.c (cgraph_mark_inline_edge): Returns boolean, true
iff a new cgraph edges have been created.
(cgraph_decide_inlining): New variable redo_always_inline.
Flattening and always_inlining loop until callgraph stabilizes.
* ipa-prop.c (update_call_notes_after_inlining): Returns boolean,
true iff new cgraph edges have been created.
(propagate_info_to_inlined_callees): Likewise.
(ipa_propagate_indirect_call_infos): Likewise.
From-SVN: r140293
2008-09-11 19:03:23 +02:00
|
|
|
struct ipcp_lattice *lat = ipcp_get_lattice (info, i);
|
2008-05-06 16:15:18 +02:00
|
|
|
if (lat->type == IPA_TOP)
|
|
|
|
{
|
|
|
|
prop_again = true;
|
2008-08-29 18:41:35 +02:00
|
|
|
if (dump_file)
|
|
|
|
{
|
|
|
|
fprintf (dump_file, "Forcing param ");
|
ipa-prop.h (struct ipa_param_flags): Removed.
2008-09-11 Martin Jambor <mjambor@suse.cz>
* ipa-prop.h (struct ipa_param_flags): Removed.
(struct ipa_param_descriptor): New structure.
(struct ipa_node_params): ipcp_lattices, param_decls and
param_flags moved to ipa_param_description.
(ipa_get_ith_param): Renamed to ipa_get_param, changed to access
descriptors. Renamed all users.
(ipa_is_ith_param_modified): Renamed to ipa_is_param_modified,
changed to access descriptors. Renamed all users.
(ipa_is_ith_param_called): Renamed to ipa_is_param_called, changed
to access descriptors. Renamed all users.
* ipa-cp.c (ipcp_init_cloned_node): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
(ipcp_analyze_node): Likewise.
(ipcp_get_ith_lattice): Renamed to ipcp_get_lattice, changed to access
descriptors. Renamed all users.
(ipcp_initialize_node_lattices): Remove allocation.
* ipa-inline.c (inline_indirect_intraprocedural_analysis): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
* ipa-prop.c (ipa_create_param_decls_array): Renamed to
ipa_populate_param_decls, made static, added parameter info,
renamed mt to node, removed allocation, changed to use
descriptors.
(ipa_count_formal_params): Made static, added parameter info,
renamed mt to node.
(ipa_initialize_node_params): New function.
(ipa_check_stmt_modifications): Changed to use descriptors.
(ipa_detect_param_modifications): Removed allocation, changed to
use descriptors.
(ipa_note_param_call): Changed to use descriptors.
(ipa_analyze_params_uses): Removed allocation.
(ipa_free_node_params_substructures): Changed to use descriptors.
(ipa_edge_duplication_hook): Use the unused attribute.
(ipa_node_duplication_hook): Use the unused attribute, changed to
use descriptors, changed to duplicate descriptors.
* ipa-inline.c (cgraph_mark_inline_edge): New parameter new_edges,
changed all callers. Call ipa_propagate_indirect_call_infos if doing
indirect inlining. Made static.
(cgraph_decide_inlining): Freeing ipa-prop structures after inlining
functions called only once.
(cgraph_decide_recursive_inlining): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining_of_small_functions): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining): Don't call
ipa_propagate_indirect_call_infos.
* ipa-prop.c: Check that vectors are allocated.
* ipa-inline.c (cgraph_mark_inline_edge): Returns boolean, true
iff a new cgraph edges have been created.
(cgraph_decide_inlining): New variable redo_always_inline.
Flattening and always_inlining loop until callgraph stabilizes.
* ipa-prop.c (update_call_notes_after_inlining): Returns boolean,
true iff new cgraph edges have been created.
(propagate_info_to_inlined_callees): Likewise.
(ipa_propagate_indirect_call_infos): Likewise.
From-SVN: r140293
2008-09-11 19:03:23 +02:00
|
|
|
print_generic_expr (dump_file, ipa_get_param (info, i), 0);
|
2008-08-29 18:41:35 +02:00
|
|
|
fprintf (dump_file, " of node %s to bottom.\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
}
|
2008-05-06 16:15:18 +02:00
|
|
|
lat->type = IPA_BOTTOM;
|
|
|
|
}
|
2010-08-05 15:23:07 +02:00
|
|
|
if (!ipa_param_cannot_devirtualize_p (info, i)
|
|
|
|
&& ipa_param_types_vec_empty (info, i))
|
|
|
|
{
|
|
|
|
prop_again = true;
|
|
|
|
ipa_set_param_cannot_devirtualize (info, i);
|
|
|
|
if (dump_file)
|
|
|
|
{
|
|
|
|
fprintf (dump_file, "Marking param ");
|
|
|
|
print_generic_expr (dump_file, ipa_get_param (info, i), 0);
|
|
|
|
fprintf (dump_file, " of node %s as unusable for "
|
|
|
|
"devirtualization.\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
}
|
|
|
|
}
|
2008-05-06 16:15:18 +02:00
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
return prop_again;
|
|
|
|
}
|
|
|
|
|
2010-08-05 15:23:07 +02:00
|
|
|
/* Insert BINFO to the list of known types of parameter number I of the
|
|
|
|
function described by CALLEE_INFO. Return true iff the type information
|
|
|
|
associated with the callee parameter changed in any way. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
ipcp_add_param_type (struct ipa_node_params *callee_info, int i, tree binfo)
|
|
|
|
{
|
|
|
|
int j, count;
|
|
|
|
|
|
|
|
if (ipa_param_cannot_devirtualize_p (callee_info, i))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (callee_info->params[i].types)
|
|
|
|
{
|
|
|
|
count = VEC_length (tree, callee_info->params[i].types);
|
|
|
|
for (j = 0; j < count; j++)
|
|
|
|
if (VEC_index (tree, callee_info->params[i].types, j) == binfo)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (VEC_length (tree, callee_info->params[i].types)
|
|
|
|
== (unsigned) PARAM_VALUE (PARAM_DEVIRT_TYPE_LIST_SIZE))
|
|
|
|
return !ipa_set_param_cannot_devirtualize (callee_info, i);
|
|
|
|
|
|
|
|
VEC_safe_push (tree, heap, callee_info->params[i].types, binfo);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Copy known types information for parameter number CALLEE_IDX of CALLEE_INFO
|
|
|
|
from a parameter of CALLER_INFO as described by JF. Return true iff the
|
|
|
|
type information changed in any way. JF must be a pass-through or an
|
|
|
|
ancestor jump function. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
ipcp_copy_types (struct ipa_node_params *caller_info,
|
|
|
|
struct ipa_node_params *callee_info,
|
|
|
|
int callee_idx, struct ipa_jump_func *jf)
|
|
|
|
{
|
|
|
|
int caller_idx, j, count;
|
|
|
|
bool res;
|
|
|
|
|
|
|
|
if (ipa_param_cannot_devirtualize_p (callee_info, callee_idx))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (jf->type == IPA_JF_PASS_THROUGH)
|
|
|
|
{
|
|
|
|
if (jf->value.pass_through.operation != NOP_EXPR)
|
|
|
|
{
|
|
|
|
ipa_set_param_cannot_devirtualize (callee_info, callee_idx);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
caller_idx = jf->value.pass_through.formal_id;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
caller_idx = jf->value.ancestor.formal_id;
|
|
|
|
|
|
|
|
if (ipa_param_cannot_devirtualize_p (caller_info, caller_idx))
|
|
|
|
{
|
|
|
|
ipa_set_param_cannot_devirtualize (callee_info, callee_idx);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!caller_info->params[caller_idx].types)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
res = false;
|
|
|
|
count = VEC_length (tree, caller_info->params[caller_idx].types);
|
|
|
|
for (j = 0; j < count; j++)
|
|
|
|
{
|
|
|
|
tree binfo = VEC_index (tree, caller_info->params[caller_idx].types, j);
|
|
|
|
if (jf->type == IPA_JF_ANCESTOR)
|
|
|
|
{
|
|
|
|
binfo = get_binfo_at_offset (binfo, jf->value.ancestor.offset,
|
|
|
|
jf->value.ancestor.type);
|
|
|
|
if (!binfo)
|
|
|
|
{
|
|
|
|
ipa_set_param_cannot_devirtualize (callee_info, callee_idx);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
res |= ipcp_add_param_type (callee_info, callee_idx, binfo);
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Propagate type information for parameter of CALLEE_INFO number I as
|
|
|
|
described by JF. CALLER_INFO describes the caller. Return true iff the
|
|
|
|
type information changed in any way. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
ipcp_propagate_types (struct ipa_node_params *caller_info,
|
|
|
|
struct ipa_node_params *callee_info,
|
|
|
|
struct ipa_jump_func *jf, int i)
|
|
|
|
{
|
|
|
|
switch (jf->type)
|
|
|
|
{
|
|
|
|
case IPA_JF_UNKNOWN:
|
|
|
|
case IPA_JF_CONST_MEMBER_PTR:
|
2010-12-22 13:56:54 +01:00
|
|
|
case IPA_JF_CONST:
|
2010-08-05 15:23:07 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IPA_JF_KNOWN_TYPE:
|
|
|
|
return ipcp_add_param_type (callee_info, i, jf->value.base_binfo);
|
|
|
|
|
|
|
|
case IPA_JF_PASS_THROUGH:
|
|
|
|
case IPA_JF_ANCESTOR:
|
|
|
|
return ipcp_copy_types (caller_info, callee_info, i, jf);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If we reach this we cannot use this parameter for devirtualization. */
|
|
|
|
return !ipa_set_param_cannot_devirtualize (callee_info, i);
|
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Interprocedural analysis. The algorithm propagates constants from the
|
|
|
|
caller's parameters to the callee's arguments. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
|
|
|
ipcp_propagate_stage (void)
|
|
|
|
{
|
|
|
|
int i;
|
2008-05-06 16:15:18 +02:00
|
|
|
struct ipcp_lattice inc_lat = { IPA_BOTTOM, NULL };
|
|
|
|
struct ipcp_lattice new_lat = { IPA_BOTTOM, NULL };
|
|
|
|
struct ipcp_lattice *dest_lat;
|
2005-08-01 09:26:30 +02:00
|
|
|
struct cgraph_edge *cs;
|
|
|
|
struct ipa_jump_func *jump_func;
|
2008-04-30 12:01:59 +02:00
|
|
|
struct ipa_func_list *wl;
|
2005-08-01 09:26:30 +02:00
|
|
|
int count;
|
|
|
|
|
2008-07-17 15:23:32 +02:00
|
|
|
ipa_check_create_node_params ();
|
|
|
|
ipa_check_create_edge_args ();
|
2008-08-29 18:41:35 +02:00
|
|
|
|
2008-04-30 12:01:59 +02:00
|
|
|
/* Initialize worklist to contain all functions. */
|
|
|
|
wl = ipa_init_func_list ();
|
|
|
|
while (wl)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
struct cgraph_node *node = ipa_pop_func_from_list (&wl);
|
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
|
|
|
|
|
|
|
for (cs = node->callees; cs; cs = cs->next_callee)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
struct ipa_node_params *callee_info = IPA_NODE_REF (cs->callee);
|
|
|
|
struct ipa_edge_args *args = IPA_EDGE_REF (cs);
|
|
|
|
|
ipa-cp.c (ipcp_write_summary, [...]): New functions.
* ipa-cp.c (ipcp_write_summary, ipcp_read_summary): New functions.
(pass_ipa_cp): Register them.
(ipcp_init_stage): Analyze all functions for whopr/lto.
(ipcp_propagate_stage): Skip external calls.
(ipcp_iterate_stage): Call ipa_update_after_lto_read if needed.
* ipa-reference.c (write_node_summary_p): Fix thinko about availability.
* cgraphunit.c (ipa_passes): When in lto, ne er produce new summaries;
when in ltrans, skip executing of ipa passes since everything should've
been done.
* ipa-inline.c (cgraph_decide_inlining): Remove FIXMEs.
(inline_generate_summary): Likewise.
(inline_read_summary): New function.
(inline_write_summary): New function.
(pass_ipa_inline): Register new hooks.
* ipa-prop.c: Inlcude lto-streamer.h
(ipa_edge_args_vector): Update declaration.
(ipa_count_arguments, ipa_compute_jump_functions,
ipa_free_edge_args_substructures): Move ipa_edge_args_vector into ggc.
(ipa_write_jump_function, ipa_read_jump_function, ipa_write_node_info,
ipa_read_node_info): New static functions.
(ipa_prop_write_jump_functions, ipa_prop_read_jump_functions): Update.
(duplicate_array): Use xmalloc.
(duplicate_ggc_array): New.
(ipa_edge_duplication_hook): Use it.
(ipa_update_after_lto_read): New function.
* ipa-prop.h (ipa_prop_write_jump_functions,
ipa_prop_read_jump_functions): Declare.
(ipa_pass_through_data, ipa_ancestor_jf_data, ipa_member_ptr_cst,
jump_func_value, ipa_member_ptr_cst, ipa_edge_args): Add GTY markers.
(ipa_edge_args_vector): Move into GGC.
(ipa_check_create_edge_args): Update.
(ipa_update_after_lto_read): New.
* passes.c (ipa_write_summaries_1): When in wpa, do not write summaries.
(ipa_read_summaries): When in ltrans, so not read summaries.
* lto-streamer.c (lto_get_section_name): Add LTO_section_jump_functions.
* lto-streamer.h (LTO_section_jump_functions): New section.
(produce_asm): Declare.
* lto-cgraph.c (output_cgraph): Output edges in reverse order.
* lto-streamer-out.c (produce_asm): Export.
* lto-streamer-in.c: Include tree-pass.h
(input_function): Free dominance info when done.
(lto_read_body): Push ipa_inline in ltrans stage.
* gengtype.c (open_base_files): Add ipa-prop.h into includes.
* Makefile.in (GTFILES): Add ipa-prop.h
* lto.c (lto_fixup_jump_functions): New function.
(lto_fixup_decls): Use it.
From-SVN: r153449
2009-10-22 12:02:29 +02:00
|
|
|
if (ipa_is_called_with_var_arguments (callee_info)
|
|
|
|
|| !cs->callee->analyzed
|
|
|
|
|| ipa_is_called_with_var_arguments (callee_info))
|
2008-04-30 12:01:59 +02:00
|
|
|
continue;
|
2008-05-06 16:15:18 +02:00
|
|
|
|
|
|
|
count = ipa_get_cs_argument_count (args);
|
2005-08-01 09:26:30 +02:00
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
jump_func = ipa_get_ith_jump_func (args, i);
|
|
|
|
ipcp_lattice_from_jfunc (info, &inc_lat, jump_func);
|
ipa-prop.h (struct ipa_param_flags): Removed.
2008-09-11 Martin Jambor <mjambor@suse.cz>
* ipa-prop.h (struct ipa_param_flags): Removed.
(struct ipa_param_descriptor): New structure.
(struct ipa_node_params): ipcp_lattices, param_decls and
param_flags moved to ipa_param_description.
(ipa_get_ith_param): Renamed to ipa_get_param, changed to access
descriptors. Renamed all users.
(ipa_is_ith_param_modified): Renamed to ipa_is_param_modified,
changed to access descriptors. Renamed all users.
(ipa_is_ith_param_called): Renamed to ipa_is_param_called, changed
to access descriptors. Renamed all users.
* ipa-cp.c (ipcp_init_cloned_node): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
(ipcp_analyze_node): Likewise.
(ipcp_get_ith_lattice): Renamed to ipcp_get_lattice, changed to access
descriptors. Renamed all users.
(ipcp_initialize_node_lattices): Remove allocation.
* ipa-inline.c (inline_indirect_intraprocedural_analysis): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
* ipa-prop.c (ipa_create_param_decls_array): Renamed to
ipa_populate_param_decls, made static, added parameter info,
renamed mt to node, removed allocation, changed to use
descriptors.
(ipa_count_formal_params): Made static, added parameter info,
renamed mt to node.
(ipa_initialize_node_params): New function.
(ipa_check_stmt_modifications): Changed to use descriptors.
(ipa_detect_param_modifications): Removed allocation, changed to
use descriptors.
(ipa_note_param_call): Changed to use descriptors.
(ipa_analyze_params_uses): Removed allocation.
(ipa_free_node_params_substructures): Changed to use descriptors.
(ipa_edge_duplication_hook): Use the unused attribute.
(ipa_node_duplication_hook): Use the unused attribute, changed to
use descriptors, changed to duplicate descriptors.
* ipa-inline.c (cgraph_mark_inline_edge): New parameter new_edges,
changed all callers. Call ipa_propagate_indirect_call_infos if doing
indirect inlining. Made static.
(cgraph_decide_inlining): Freeing ipa-prop structures after inlining
functions called only once.
(cgraph_decide_recursive_inlining): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining_of_small_functions): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining): Don't call
ipa_propagate_indirect_call_infos.
* ipa-prop.c: Check that vectors are allocated.
* ipa-inline.c (cgraph_mark_inline_edge): Returns boolean, true
iff a new cgraph edges have been created.
(cgraph_decide_inlining): New variable redo_always_inline.
Flattening and always_inlining loop until callgraph stabilizes.
* ipa-prop.c (update_call_notes_after_inlining): Returns boolean,
true iff new cgraph edges have been created.
(propagate_info_to_inlined_callees): Likewise.
(ipa_propagate_indirect_call_infos): Likewise.
From-SVN: r140293
2008-09-11 19:03:23 +02:00
|
|
|
dest_lat = ipcp_get_lattice (callee_info, i);
|
2008-05-06 16:15:18 +02:00
|
|
|
ipa_lattice_meet (&new_lat, &inc_lat, dest_lat);
|
|
|
|
if (ipcp_lattice_changed (&new_lat, dest_lat))
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
dest_lat->type = new_lat.type;
|
|
|
|
dest_lat->constant = new_lat.constant;
|
|
|
|
ipa_push_func_to_list (&wl, cs->callee);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2010-08-05 15:23:07 +02:00
|
|
|
|
|
|
|
if (ipcp_propagate_types (info, callee_info, jump_func, i))
|
|
|
|
ipa_push_func_to_list (&wl, cs->callee);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the constant propagation algorithm and re-call it if necessary
|
|
|
|
(if there are undetermined values left). */
|
|
|
|
static void
|
|
|
|
ipcp_iterate_stage (void)
|
|
|
|
{
|
2008-08-29 18:41:35 +02:00
|
|
|
struct cgraph_node *node;
|
|
|
|
n_cloning_candidates = 0;
|
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "\nIPA iterate stage:\n\n");
|
ipa-cp.c (ipcp_write_summary, [...]): New functions.
* ipa-cp.c (ipcp_write_summary, ipcp_read_summary): New functions.
(pass_ipa_cp): Register them.
(ipcp_init_stage): Analyze all functions for whopr/lto.
(ipcp_propagate_stage): Skip external calls.
(ipcp_iterate_stage): Call ipa_update_after_lto_read if needed.
* ipa-reference.c (write_node_summary_p): Fix thinko about availability.
* cgraphunit.c (ipa_passes): When in lto, ne er produce new summaries;
when in ltrans, skip executing of ipa passes since everything should've
been done.
* ipa-inline.c (cgraph_decide_inlining): Remove FIXMEs.
(inline_generate_summary): Likewise.
(inline_read_summary): New function.
(inline_write_summary): New function.
(pass_ipa_inline): Register new hooks.
* ipa-prop.c: Inlcude lto-streamer.h
(ipa_edge_args_vector): Update declaration.
(ipa_count_arguments, ipa_compute_jump_functions,
ipa_free_edge_args_substructures): Move ipa_edge_args_vector into ggc.
(ipa_write_jump_function, ipa_read_jump_function, ipa_write_node_info,
ipa_read_node_info): New static functions.
(ipa_prop_write_jump_functions, ipa_prop_read_jump_functions): Update.
(duplicate_array): Use xmalloc.
(duplicate_ggc_array): New.
(ipa_edge_duplication_hook): Use it.
(ipa_update_after_lto_read): New function.
* ipa-prop.h (ipa_prop_write_jump_functions,
ipa_prop_read_jump_functions): Declare.
(ipa_pass_through_data, ipa_ancestor_jf_data, ipa_member_ptr_cst,
jump_func_value, ipa_member_ptr_cst, ipa_edge_args): Add GTY markers.
(ipa_edge_args_vector): Move into GGC.
(ipa_check_create_edge_args): Update.
(ipa_update_after_lto_read): New.
* passes.c (ipa_write_summaries_1): When in wpa, do not write summaries.
(ipa_read_summaries): When in ltrans, so not read summaries.
* lto-streamer.c (lto_get_section_name): Add LTO_section_jump_functions.
* lto-streamer.h (LTO_section_jump_functions): New section.
(produce_asm): Declare.
* lto-cgraph.c (output_cgraph): Output edges in reverse order.
* lto-streamer-out.c (produce_asm): Export.
* lto-streamer-in.c: Include tree-pass.h
(input_function): Free dominance info when done.
(lto_read_body): Push ipa_inline in ltrans stage.
* gengtype.c (open_base_files): Add ipa-prop.h into includes.
* Makefile.in (GTFILES): Add ipa-prop.h
* lto.c (lto_fixup_jump_functions): New function.
(lto_fixup_decls): Use it.
From-SVN: r153449
2009-10-22 12:02:29 +02:00
|
|
|
|
|
|
|
if (in_lto_p)
|
|
|
|
ipa_update_after_lto_read ();
|
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
for (node = cgraph_nodes; node; node = node->next)
|
|
|
|
{
|
|
|
|
ipcp_initialize_node_lattices (node);
|
|
|
|
ipcp_compute_node_scale (node);
|
|
|
|
}
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
{
|
|
|
|
ipcp_print_all_lattices (dump_file);
|
|
|
|
ipcp_function_scale_print (dump_file);
|
|
|
|
}
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
ipcp_propagate_stage ();
|
2008-05-06 16:15:18 +02:00
|
|
|
if (ipcp_change_tops_to_bottom ())
|
|
|
|
/* Some lattices have changed from IPA_TOP to IPA_BOTTOM.
|
2005-08-01 09:26:30 +02:00
|
|
|
This change should be propagated. */
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
|
|
|
gcc_assert (n_cloning_candidates);
|
|
|
|
ipcp_propagate_stage ();
|
|
|
|
}
|
|
|
|
if (dump_file)
|
|
|
|
{
|
|
|
|
fprintf (dump_file, "\nIPA lattices after propagation:\n");
|
|
|
|
ipcp_print_all_lattices (dump_file);
|
|
|
|
if (dump_flags & TDF_DETAILS)
|
|
|
|
ipcp_print_profile_data (dump_file);
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Check conditions to forbid constant insertion to function described by
|
|
|
|
NODE. */
|
|
|
|
static inline bool
|
2008-08-29 13:31:40 +02:00
|
|
|
ipcp_node_modifiable_p (struct cgraph_node *node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-08-29 13:31:40 +02:00
|
|
|
/* Once we will be able to do in-place replacement, we can be more
|
|
|
|
lax here. */
|
2009-06-26 20:23:32 +02:00
|
|
|
return ipcp_versionable_function_p (node);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Print count scale data structures. */
|
|
|
|
static void
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_function_scale_print (FILE * f)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
struct cgraph_node *node;
|
|
|
|
|
|
|
|
for (node = cgraph_nodes; node; node = node->next)
|
|
|
|
{
|
2008-07-17 15:23:32 +02:00
|
|
|
if (!node->analyzed)
|
|
|
|
continue;
|
2005-08-01 09:26:30 +02:00
|
|
|
fprintf (f, "printing scale for %s: ", cgraph_node_name (node));
|
|
|
|
fprintf (f, "value is " HOST_WIDE_INT_PRINT_DEC
|
2008-05-06 16:15:18 +02:00
|
|
|
" \n", (HOST_WIDE_INT) ipcp_get_node_scale (node));
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Print counts of all cgraph nodes. */
|
|
|
|
static void
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_print_func_profile_counts (FILE * f)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
struct cgraph_node *node;
|
|
|
|
|
|
|
|
for (node = cgraph_nodes; node; node = node->next)
|
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
fprintf (f, "function %s: ", cgraph_node_name (node));
|
2005-08-01 09:26:30 +02:00
|
|
|
fprintf (f, "count is " HOST_WIDE_INT_PRINT_DEC
|
|
|
|
" \n", (HOST_WIDE_INT) node->count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Makefile.in, [...]: Fix comment/doc typos.
* Makefile.in, cfgexpand.c, cfgloop.h, cfgloopmanip.c,
config.gcc, ipa-cp.c, ipa-prop.c, ipa-prop.h, reg-stack.c,
tree-ssa-structalias.c, tree-vrp.c, value-prof.c, vec.h,
config/linux.h, config/alpha/alpha.h, config/alpha/linux.h,
config/alpha/predicates.md, config/arc/arc.h,
config/arm/arm.h, config/arm/ieee754-df.S,
config/arm/ieee754-sf.S, config/bfin/bfin.c,
config/bfin/bfin.h, config/c4x/c4x.h, config/crx/crx.c,
config/fr30/fr30.h, config/frv/frv.h, config/h8300/h8300.h,
config/i386/i386.h, config/ia64/ia64.c, config/ia64/ia64.h,
config/m68hc11/m68hc11.h, config/mips/mips.c,
config/mips/mips.h, config/mips/openbsd.h,
config/mn10300/mn10300.h, config/pa/pa.c, config/pa/pa.h,
config/pdp11/pdp11.h, config/rs6000/linux-unwind.h,
config/rs6000/rs6000.c, config/rs6000/rs6000.h,
config/s390/s390.c, config/sh/sh.c, config/sh/sh.h,
config/sparc/linux.h, config/sparc/linux64.h,
config/sparc/sparc.h, config/v850/v850.h, config/vax/vax.h,
doc/extend.texi, doc/gcov.texi, doc/install.texi,
doc/invoke.texi, doc/rtl.texi, doc/tm.texi: Fix comment/doc
typos. Follow spelling conventions.
From-SVN: r102809
2005-08-06 15:26:35 +02:00
|
|
|
/* Print counts of all cgraph edges. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_print_call_profile_counts (FILE * f)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
struct cgraph_node *node;
|
|
|
|
struct cgraph_edge *cs;
|
|
|
|
|
|
|
|
for (node = cgraph_nodes; node; node = node->next)
|
|
|
|
{
|
|
|
|
for (cs = node->callees; cs; cs = cs->next_callee)
|
|
|
|
{
|
|
|
|
fprintf (f, "%s -> %s ", cgraph_node_name (cs->caller),
|
|
|
|
cgraph_node_name (cs->callee));
|
|
|
|
fprintf (f, "count is " HOST_WIDE_INT_PRINT_DEC " \n",
|
|
|
|
(HOST_WIDE_INT) cs->count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Print profile info for all functions. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_print_profile_data (FILE * f)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
fprintf (f, "\nNODE COUNTS :\n");
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_print_func_profile_counts (f);
|
2005-08-01 09:26:30 +02:00
|
|
|
fprintf (f, "\nCS COUNTS stage:\n");
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_print_call_profile_counts (f);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Build and initialize ipa_replace_map struct according to LAT. This struct is
|
|
|
|
processed by versioning, which operates according to the flags set.
|
|
|
|
PARM_TREE is the formal parameter found to be constant. LAT represents the
|
|
|
|
constant. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static struct ipa_replace_map *
|
2008-08-24 00:25:20 +02:00
|
|
|
ipcp_create_replace_map (tree parm_tree, struct ipcp_lattice *lat)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
struct ipa_replace_map *replace_map;
|
|
|
|
tree const_val;
|
|
|
|
|
2008-08-24 00:25:20 +02:00
|
|
|
const_val = build_const_val (lat, TREE_TYPE (parm_tree));
|
2011-03-05 00:07:20 +01:00
|
|
|
if (const_val == NULL_TREE)
|
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
{
|
|
|
|
fprintf (dump_file, " const ");
|
|
|
|
print_generic_expr (dump_file, lat->constant, 0);
|
|
|
|
fprintf (dump_file, " can't be converted to param ");
|
|
|
|
print_generic_expr (dump_file, parm_tree, 0);
|
|
|
|
fprintf (dump_file, "\n");
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
replace_map = ggc_alloc_ipa_replace_map ();
|
2008-08-29 13:31:40 +02:00
|
|
|
if (dump_file)
|
|
|
|
{
|
|
|
|
fprintf (dump_file, " replacing param ");
|
|
|
|
print_generic_expr (dump_file, parm_tree, 0);
|
|
|
|
fprintf (dump_file, " with const ");
|
|
|
|
print_generic_expr (dump_file, const_val, 0);
|
|
|
|
fprintf (dump_file, "\n");
|
|
|
|
}
|
2008-08-24 00:25:20 +02:00
|
|
|
replace_map->old_tree = parm_tree;
|
|
|
|
replace_map->new_tree = const_val;
|
|
|
|
replace_map->replace_p = true;
|
|
|
|
replace_map->ref_p = false;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
|
|
|
return replace_map;
|
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Return true if this callsite should be redirected to the original callee
|
|
|
|
(instead of the cloned one). */
|
2005-08-01 09:26:30 +02:00
|
|
|
static bool
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_need_redirect_p (struct cgraph_edge *cs)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
struct ipa_node_params *orig_callee_info;
|
2005-08-01 09:26:30 +02:00
|
|
|
int i, count;
|
2008-08-24 22:09:32 +02:00
|
|
|
struct cgraph_node *node = cs->callee, *orig;
|
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
if (!n_cloning_candidates)
|
2008-08-29 13:31:40 +02:00
|
|
|
return false;
|
|
|
|
|
2008-08-24 22:09:32 +02:00
|
|
|
if ((orig = ipcp_get_orig_node (node)) != NULL)
|
|
|
|
node = orig;
|
|
|
|
if (ipcp_get_orig_node (cs->caller))
|
|
|
|
return false;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2008-08-24 22:09:32 +02:00
|
|
|
orig_callee_info = IPA_NODE_REF (node);
|
2008-05-06 16:15:18 +02:00
|
|
|
count = ipa_get_param_count (orig_callee_info);
|
2005-08-01 09:26:30 +02:00
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
ipa-prop.h (struct ipa_param_flags): Removed.
2008-09-11 Martin Jambor <mjambor@suse.cz>
* ipa-prop.h (struct ipa_param_flags): Removed.
(struct ipa_param_descriptor): New structure.
(struct ipa_node_params): ipcp_lattices, param_decls and
param_flags moved to ipa_param_description.
(ipa_get_ith_param): Renamed to ipa_get_param, changed to access
descriptors. Renamed all users.
(ipa_is_ith_param_modified): Renamed to ipa_is_param_modified,
changed to access descriptors. Renamed all users.
(ipa_is_ith_param_called): Renamed to ipa_is_param_called, changed
to access descriptors. Renamed all users.
* ipa-cp.c (ipcp_init_cloned_node): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
(ipcp_analyze_node): Likewise.
(ipcp_get_ith_lattice): Renamed to ipcp_get_lattice, changed to access
descriptors. Renamed all users.
(ipcp_initialize_node_lattices): Remove allocation.
* ipa-inline.c (inline_indirect_intraprocedural_analysis): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
* ipa-prop.c (ipa_create_param_decls_array): Renamed to
ipa_populate_param_decls, made static, added parameter info,
renamed mt to node, removed allocation, changed to use
descriptors.
(ipa_count_formal_params): Made static, added parameter info,
renamed mt to node.
(ipa_initialize_node_params): New function.
(ipa_check_stmt_modifications): Changed to use descriptors.
(ipa_detect_param_modifications): Removed allocation, changed to
use descriptors.
(ipa_note_param_call): Changed to use descriptors.
(ipa_analyze_params_uses): Removed allocation.
(ipa_free_node_params_substructures): Changed to use descriptors.
(ipa_edge_duplication_hook): Use the unused attribute.
(ipa_node_duplication_hook): Use the unused attribute, changed to
use descriptors, changed to duplicate descriptors.
* ipa-inline.c (cgraph_mark_inline_edge): New parameter new_edges,
changed all callers. Call ipa_propagate_indirect_call_infos if doing
indirect inlining. Made static.
(cgraph_decide_inlining): Freeing ipa-prop structures after inlining
functions called only once.
(cgraph_decide_recursive_inlining): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining_of_small_functions): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining): Don't call
ipa_propagate_indirect_call_infos.
* ipa-prop.c: Check that vectors are allocated.
* ipa-inline.c (cgraph_mark_inline_edge): Returns boolean, true
iff a new cgraph edges have been created.
(cgraph_decide_inlining): New variable redo_always_inline.
Flattening and always_inlining loop until callgraph stabilizes.
* ipa-prop.c (update_call_notes_after_inlining): Returns boolean,
true iff new cgraph edges have been created.
(propagate_info_to_inlined_callees): Likewise.
(ipa_propagate_indirect_call_infos): Likewise.
From-SVN: r140293
2008-09-11 19:03:23 +02:00
|
|
|
struct ipcp_lattice *lat = ipcp_get_lattice (orig_callee_info, i);
|
2010-08-05 15:23:07 +02:00
|
|
|
struct ipa_jump_func *jump_func;
|
|
|
|
|
|
|
|
jump_func = ipa_get_ith_jump_func (IPA_EDGE_REF (cs), i);
|
|
|
|
if ((ipcp_lat_is_const (lat)
|
|
|
|
&& jump_func->type != IPA_JF_CONST)
|
|
|
|
|| (!ipa_param_cannot_devirtualize_p (orig_callee_info, i)
|
|
|
|
&& !ipa_param_types_vec_empty (orig_callee_info, i)
|
|
|
|
&& jump_func->type != IPA_JF_CONST
|
|
|
|
&& jump_func->type != IPA_JF_KNOWN_TYPE))
|
|
|
|
return true;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Fix the callsites and the call graph after function cloning was done. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
|
|
|
ipcp_update_callgraph (void)
|
|
|
|
{
|
2008-08-29 13:31:40 +02:00
|
|
|
struct cgraph_node *node;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
|
|
|
for (node = cgraph_nodes; node; node = node->next)
|
2008-08-29 13:31:40 +02:00
|
|
|
if (node->analyzed && ipcp_node_is_clone (node))
|
|
|
|
{
|
2011-01-26 15:06:20 +01:00
|
|
|
bitmap args_to_skip = NULL;
|
2008-08-29 13:31:40 +02:00
|
|
|
struct cgraph_node *orig_node = ipcp_get_orig_node (node);
|
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (orig_node);
|
|
|
|
int i, count = ipa_get_param_count (info);
|
|
|
|
struct cgraph_edge *cs, *next;
|
|
|
|
|
2011-01-26 15:06:20 +01:00
|
|
|
if (node->local.can_change_signature)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-01-26 15:06:20 +01:00
|
|
|
args_to_skip = BITMAP_ALLOC (NULL);
|
|
|
|
for (i = 0; i < count; i++)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-01-26 15:06:20 +01:00
|
|
|
struct ipcp_lattice *lat = ipcp_get_lattice (info, i);
|
|
|
|
|
|
|
|
/* We can proactively remove obviously unused arguments. */
|
|
|
|
if (!ipa_is_param_used (info, i))
|
|
|
|
{
|
|
|
|
bitmap_set_bit (args_to_skip, i);
|
|
|
|
continue;
|
|
|
|
}
|
2008-08-29 13:31:40 +02:00
|
|
|
|
2011-01-26 15:06:20 +01:00
|
|
|
if (lat->type == IPA_CONST_VALUE)
|
|
|
|
bitmap_set_bit (args_to_skip, i);
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2008-08-29 13:31:40 +02:00
|
|
|
for (cs = node->callers; cs; cs = next)
|
|
|
|
{
|
|
|
|
next = cs->next_caller;
|
2009-05-08 21:19:51 +02:00
|
|
|
if (!ipcp_node_is_clone (cs->caller) && ipcp_need_redirect_p (cs))
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Redirecting edge %s/%i -> %s/%i "
|
|
|
|
"back to %s/%i.",
|
|
|
|
cgraph_node_name (cs->caller), cs->caller->uid,
|
|
|
|
cgraph_node_name (cs->callee), cs->callee->uid,
|
|
|
|
cgraph_node_name (orig_node), orig_node->uid);
|
|
|
|
cgraph_redirect_edge_callee (cs, orig_node);
|
|
|
|
}
|
2008-08-29 13:31:40 +02:00
|
|
|
}
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Update profiling info for versioned functions and the functions they were
|
|
|
|
versioned from. */
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
|
|
|
ipcp_update_profiling (void)
|
|
|
|
{
|
|
|
|
struct cgraph_node *node, *orig_node;
|
|
|
|
gcov_type scale, scale_complement;
|
|
|
|
struct cgraph_edge *cs;
|
|
|
|
|
|
|
|
for (node = cgraph_nodes; node; node = node->next)
|
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
if (ipcp_node_is_clone (node))
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
orig_node = ipcp_get_orig_node (node);
|
|
|
|
scale = ipcp_get_node_scale (orig_node);
|
2005-08-01 09:26:30 +02:00
|
|
|
node->count = orig_node->count * scale / REG_BR_PROB_BASE;
|
|
|
|
scale_complement = REG_BR_PROB_BASE - scale;
|
2011-04-08 23:03:12 +02:00
|
|
|
|
|
|
|
/* Negative scale complement can result from insane profile data
|
|
|
|
in which the total incoming edge counts in this module is
|
|
|
|
larger than the callee's entry count. The insane profile data
|
|
|
|
usually gets generated due to the following reasons:
|
|
|
|
|
|
|
|
1) in multithreaded programs, when profile data is dumped
|
|
|
|
to gcda files in gcov_exit, some other threads are still running.
|
|
|
|
The profile counters are dumped in bottom up order (call graph).
|
|
|
|
The caller's BB counters may still be updated while the callee's
|
|
|
|
counter data is already saved to disk.
|
|
|
|
|
|
|
|
2) Comdat functions: comdat functions' profile data are not
|
|
|
|
allocated in comdat. When a comdat callee function gets inlined
|
|
|
|
at some callsites after instrumentation, and the remaining calls
|
|
|
|
to this function resolves to a comdat copy in another module,
|
|
|
|
the profile counters for this function are split. This can
|
|
|
|
result in sum of incoming edge counts from this module being
|
|
|
|
larger than callee instance's entry count. */
|
|
|
|
|
|
|
|
if (scale_complement < 0 && flag_profile_correction)
|
|
|
|
scale_complement = 0;
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
orig_node->count =
|
|
|
|
orig_node->count * scale_complement / REG_BR_PROB_BASE;
|
|
|
|
for (cs = node->callees; cs; cs = cs->next_callee)
|
|
|
|
cs->count = cs->count * scale / REG_BR_PROB_BASE;
|
|
|
|
for (cs = orig_node->callees; cs; cs = cs->next_callee)
|
|
|
|
cs->count = cs->count * scale_complement / REG_BR_PROB_BASE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-31 18:45:05 +02:00
|
|
|
/* If NODE was cloned, how much would program grow? */
|
|
|
|
static long
|
|
|
|
ipcp_estimate_growth (struct cgraph_node *node)
|
2008-08-24 22:09:32 +02:00
|
|
|
{
|
2008-08-31 18:45:05 +02:00
|
|
|
struct cgraph_edge *cs;
|
|
|
|
int redirectable_node_callers = 0;
|
|
|
|
int removable_args = 0;
|
2010-07-08 18:46:49 +02:00
|
|
|
bool need_original
|
|
|
|
= !cgraph_will_be_removed_from_program_if_no_direct_calls (node);
|
2008-08-31 18:45:05 +02:00
|
|
|
struct ipa_node_params *info;
|
|
|
|
int i, count;
|
|
|
|
int growth;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2008-08-31 18:45:05 +02:00
|
|
|
for (cs = node->callers; cs != NULL; cs = cs->next_caller)
|
2008-09-22 06:24:28 +02:00
|
|
|
if (cs->caller == node || !ipcp_need_redirect_p (cs))
|
2008-08-31 18:45:05 +02:00
|
|
|
redirectable_node_callers++;
|
|
|
|
else
|
|
|
|
need_original = true;
|
|
|
|
|
2011-02-11 16:16:46 +01:00
|
|
|
/* If we will be able to fully replace original node, we never increase
|
2008-08-31 18:45:05 +02:00
|
|
|
program size. */
|
|
|
|
if (!need_original)
|
2008-09-18 19:57:05 +02:00
|
|
|
return 0;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2008-08-31 18:45:05 +02:00
|
|
|
info = IPA_NODE_REF (node);
|
|
|
|
count = ipa_get_param_count (info);
|
2011-01-26 15:06:20 +01:00
|
|
|
if (node->local.can_change_signature)
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
struct ipcp_lattice *lat = ipcp_get_lattice (info, i);
|
2008-08-31 18:45:05 +02:00
|
|
|
|
2011-01-26 15:06:20 +01:00
|
|
|
/* We can proactively remove obviously unused arguments. */
|
|
|
|
if (!ipa_is_param_used (info, i))
|
|
|
|
removable_args++;
|
2008-08-31 18:45:05 +02:00
|
|
|
|
2011-01-26 15:06:20 +01:00
|
|
|
if (lat->type == IPA_CONST_VALUE)
|
|
|
|
removable_args++;
|
|
|
|
}
|
2008-08-31 18:45:05 +02:00
|
|
|
|
|
|
|
/* We make just very simple estimate of savings for removal of operand from
|
2011-02-11 16:16:46 +01:00
|
|
|
call site. Precise cost is difficult to get, as our size metric counts
|
2008-08-31 18:45:05 +02:00
|
|
|
constants and moves as free. Generally we are looking for cases that
|
|
|
|
small function is called very many times. */
|
cgraph.c (dump_cgraph_node): Do not dump inline summaries.
* cgraph.c (dump_cgraph_node): Do not dump inline summaries.
* cgraph.h (struct inline_summary): Move to ipa-inline.h
(cgraph_local_info): Remove inline_summary.
* ipa-cp.c: Include ipa-inline.h.
(ipcp_cloning_candidate_p, ipcp_estimate_growth,
ipcp_estimate_cloning_cost, ipcp_insert_stage): Use inline_summary
accesor.
* lto-cgraph.c (lto_output_node): Do not stream inline summary.
(input_overwrite_node): Do not set inline summary.
(input_node): Do not stream inline summary.
* ipa-inline.c (cgraph_decide_inlining): Dump inline summaries.
(cgraph_decide_inlining_incrementally): Do not try to estimate overall
growth; we do not have inline parameters computed for that anyway.
(cgraph_early_inlining): After inlining compute call_stmt_sizes.
* ipa-inline.h (struct inline_summary): Move here from ipa-inline.h
(inline_summary_t): New type and VECtor.
(debug_inline_summary, dump_inline_summaries): Declare.
(inline_summary): Use VOCtor.
(estimate_edge_growth): Kill hack computing call stmt size directly.
* lto-section-in.c (lto_section_name): Add inline section.
* ipa-inline-analysis.c: Include lto-streamer.h
(node_removal_hook_holder, node_duplication_hook_holder): New holders
(inline_node_removal_hook, inline_node_duplication_hook): New functions.
(inline_summary_vec): Define.
(inline_summary_alloc, dump_inline_summary, debug_inline_summary,
dump_inline_summaries): New functions.
(estimate_function_body_sizes): Properly compute size/time of outgoing calls.
(compute_inline_parameters): Alloc inline_summary; do not compute size/time
of incomming calls.
(estimate_edge_time): Avoid missing time summary hack.
(inline_read_summary): Read inline summary info.
(inline_write_summary): Write inline summary info.
(inline_free_summary): Free all hooks and inline summary vector.
* lto-streamer.h: Add LTO_section_inline_summary section.
* Makefile.in (ipa-cp.o, ipa-inline-analysis.o): Update dependencies.
* ipa.c (cgraph_remove_unreachable_nodes): Fix dump file formating.
* lto.c: Include ipa-inline.h
(add_cgraph_node_to_partition, undo_partition): Use inline_summary accessor.
(ipa_node_duplication_hook): Fix declaration.
* Make-lang.in (lto.o): Update dependencies.
From-SVN: r172430
2011-04-14 15:26:44 +02:00
|
|
|
growth = inline_summary (node)->self_size
|
2008-08-31 18:45:05 +02:00
|
|
|
- removable_args * redirectable_node_callers;
|
|
|
|
if (growth < 0)
|
|
|
|
return 0;
|
|
|
|
return growth;
|
2008-08-24 22:09:32 +02:00
|
|
|
}
|
|
|
|
|
2008-08-31 18:45:05 +02:00
|
|
|
|
2008-08-24 22:09:32 +02:00
|
|
|
/* Estimate cost of cloning NODE. */
|
|
|
|
static long
|
|
|
|
ipcp_estimate_cloning_cost (struct cgraph_node *node)
|
|
|
|
{
|
|
|
|
int freq_sum = 1;
|
|
|
|
gcov_type count_sum = 1;
|
|
|
|
struct cgraph_edge *e;
|
|
|
|
int cost;
|
|
|
|
|
2008-08-31 18:45:05 +02:00
|
|
|
cost = ipcp_estimate_growth (node) * 1000;
|
|
|
|
if (!cost)
|
2008-08-24 22:09:32 +02:00
|
|
|
{
|
|
|
|
if (dump_file)
|
2008-08-31 18:45:05 +02:00
|
|
|
fprintf (dump_file, "Versioning of %s will save code size\n",
|
|
|
|
cgraph_node_name (node));
|
2008-08-24 22:09:32 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (e = node->callers; e; e = e->next_caller)
|
|
|
|
if (!bitmap_bit_p (dead_nodes, e->caller->uid)
|
|
|
|
&& !ipcp_need_redirect_p (e))
|
|
|
|
{
|
|
|
|
count_sum += e->count;
|
|
|
|
freq_sum += e->frequency + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (max_count)
|
|
|
|
cost /= count_sum * 1000 / max_count + 1;
|
|
|
|
else
|
|
|
|
cost /= freq_sum * 1000 / REG_BR_PROB_BASE + 1;
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Cost of versioning %s is %i, (size: %i, freq: %i)\n",
|
cgraph.c (dump_cgraph_node): Do not dump inline summaries.
* cgraph.c (dump_cgraph_node): Do not dump inline summaries.
* cgraph.h (struct inline_summary): Move to ipa-inline.h
(cgraph_local_info): Remove inline_summary.
* ipa-cp.c: Include ipa-inline.h.
(ipcp_cloning_candidate_p, ipcp_estimate_growth,
ipcp_estimate_cloning_cost, ipcp_insert_stage): Use inline_summary
accesor.
* lto-cgraph.c (lto_output_node): Do not stream inline summary.
(input_overwrite_node): Do not set inline summary.
(input_node): Do not stream inline summary.
* ipa-inline.c (cgraph_decide_inlining): Dump inline summaries.
(cgraph_decide_inlining_incrementally): Do not try to estimate overall
growth; we do not have inline parameters computed for that anyway.
(cgraph_early_inlining): After inlining compute call_stmt_sizes.
* ipa-inline.h (struct inline_summary): Move here from ipa-inline.h
(inline_summary_t): New type and VECtor.
(debug_inline_summary, dump_inline_summaries): Declare.
(inline_summary): Use VOCtor.
(estimate_edge_growth): Kill hack computing call stmt size directly.
* lto-section-in.c (lto_section_name): Add inline section.
* ipa-inline-analysis.c: Include lto-streamer.h
(node_removal_hook_holder, node_duplication_hook_holder): New holders
(inline_node_removal_hook, inline_node_duplication_hook): New functions.
(inline_summary_vec): Define.
(inline_summary_alloc, dump_inline_summary, debug_inline_summary,
dump_inline_summaries): New functions.
(estimate_function_body_sizes): Properly compute size/time of outgoing calls.
(compute_inline_parameters): Alloc inline_summary; do not compute size/time
of incomming calls.
(estimate_edge_time): Avoid missing time summary hack.
(inline_read_summary): Read inline summary info.
(inline_write_summary): Write inline summary info.
(inline_free_summary): Free all hooks and inline summary vector.
* lto-streamer.h: Add LTO_section_inline_summary section.
* Makefile.in (ipa-cp.o, ipa-inline-analysis.o): Update dependencies.
* ipa.c (cgraph_remove_unreachable_nodes): Fix dump file formating.
* lto.c: Include ipa-inline.h
(add_cgraph_node_to_partition, undo_partition): Use inline_summary accessor.
(ipa_node_duplication_hook): Fix declaration.
* Make-lang.in (lto.o): Update dependencies.
From-SVN: r172430
2011-04-14 15:26:44 +02:00
|
|
|
cgraph_node_name (node), cost, inline_summary (node)->self_size,
|
2008-08-24 22:09:32 +02:00
|
|
|
freq_sum);
|
|
|
|
return cost + 1;
|
|
|
|
}
|
|
|
|
|
2010-08-05 15:23:07 +02:00
|
|
|
/* Walk indirect calls of NODE and if any polymorphic can be turned into a
|
|
|
|
direct one now, do so. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipcp_process_devirtualization_opportunities (struct cgraph_node *node)
|
|
|
|
{
|
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
|
|
|
struct cgraph_edge *ie, *next_ie;
|
|
|
|
|
|
|
|
for (ie = node->indirect_calls; ie; ie = next_ie)
|
|
|
|
{
|
|
|
|
int param_index, types_count, j;
|
|
|
|
HOST_WIDE_INT token;
|
2010-12-15 14:19:46 +01:00
|
|
|
tree target, delta;
|
2010-08-05 15:23:07 +02:00
|
|
|
|
|
|
|
next_ie = ie->next_callee;
|
|
|
|
if (!ie->indirect_info->polymorphic)
|
|
|
|
continue;
|
|
|
|
param_index = ie->indirect_info->param_index;
|
|
|
|
if (param_index == -1
|
|
|
|
|| ipa_param_cannot_devirtualize_p (info, param_index)
|
|
|
|
|| ipa_param_types_vec_empty (info, param_index))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
token = ie->indirect_info->otr_token;
|
|
|
|
target = NULL_TREE;
|
|
|
|
types_count = VEC_length (tree, info->params[param_index].types);
|
|
|
|
for (j = 0; j < types_count; j++)
|
|
|
|
{
|
|
|
|
tree binfo = VEC_index (tree, info->params[param_index].types, j);
|
2010-12-15 14:19:46 +01:00
|
|
|
tree d;
|
2011-04-18 23:58:51 +02:00
|
|
|
tree t = gimple_get_virt_method_for_binfo (token, binfo, &d, true);
|
2010-08-05 15:23:07 +02:00
|
|
|
|
|
|
|
if (!t)
|
|
|
|
{
|
|
|
|
target = NULL_TREE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
else if (!target)
|
2010-12-15 14:19:46 +01:00
|
|
|
{
|
|
|
|
target = t;
|
|
|
|
delta = d;
|
|
|
|
}
|
|
|
|
else if (target != t || !tree_int_cst_equal (delta, d))
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
|
|
|
target = NULL_TREE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (target)
|
2010-12-15 14:19:46 +01:00
|
|
|
ipa_make_edge_direct_to_target (ie, target, delta);
|
2010-08-05 15:23:07 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-24 22:09:32 +02:00
|
|
|
/* Return number of live constant parameters. */
|
|
|
|
static int
|
|
|
|
ipcp_const_param_count (struct cgraph_node *node)
|
|
|
|
{
|
|
|
|
int const_param = 0;
|
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
|
|
|
int count = ipa_get_param_count (info);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
ipa-prop.h (struct ipa_param_flags): Removed.
2008-09-11 Martin Jambor <mjambor@suse.cz>
* ipa-prop.h (struct ipa_param_flags): Removed.
(struct ipa_param_descriptor): New structure.
(struct ipa_node_params): ipcp_lattices, param_decls and
param_flags moved to ipa_param_description.
(ipa_get_ith_param): Renamed to ipa_get_param, changed to access
descriptors. Renamed all users.
(ipa_is_ith_param_modified): Renamed to ipa_is_param_modified,
changed to access descriptors. Renamed all users.
(ipa_is_ith_param_called): Renamed to ipa_is_param_called, changed
to access descriptors. Renamed all users.
* ipa-cp.c (ipcp_init_cloned_node): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
(ipcp_analyze_node): Likewise.
(ipcp_get_ith_lattice): Renamed to ipcp_get_lattice, changed to access
descriptors. Renamed all users.
(ipcp_initialize_node_lattices): Remove allocation.
* ipa-inline.c (inline_indirect_intraprocedural_analysis): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
* ipa-prop.c (ipa_create_param_decls_array): Renamed to
ipa_populate_param_decls, made static, added parameter info,
renamed mt to node, removed allocation, changed to use
descriptors.
(ipa_count_formal_params): Made static, added parameter info,
renamed mt to node.
(ipa_initialize_node_params): New function.
(ipa_check_stmt_modifications): Changed to use descriptors.
(ipa_detect_param_modifications): Removed allocation, changed to
use descriptors.
(ipa_note_param_call): Changed to use descriptors.
(ipa_analyze_params_uses): Removed allocation.
(ipa_free_node_params_substructures): Changed to use descriptors.
(ipa_edge_duplication_hook): Use the unused attribute.
(ipa_node_duplication_hook): Use the unused attribute, changed to
use descriptors, changed to duplicate descriptors.
* ipa-inline.c (cgraph_mark_inline_edge): New parameter new_edges,
changed all callers. Call ipa_propagate_indirect_call_infos if doing
indirect inlining. Made static.
(cgraph_decide_inlining): Freeing ipa-prop structures after inlining
functions called only once.
(cgraph_decide_recursive_inlining): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining_of_small_functions): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining): Don't call
ipa_propagate_indirect_call_infos.
* ipa-prop.c: Check that vectors are allocated.
* ipa-inline.c (cgraph_mark_inline_edge): Returns boolean, true
iff a new cgraph edges have been created.
(cgraph_decide_inlining): New variable redo_always_inline.
Flattening and always_inlining loop until callgraph stabilizes.
* ipa-prop.c (update_call_notes_after_inlining): Returns boolean,
true iff new cgraph edges have been created.
(propagate_info_to_inlined_callees): Likewise.
(ipa_propagate_indirect_call_infos): Likewise.
From-SVN: r140293
2008-09-11 19:03:23 +02:00
|
|
|
struct ipcp_lattice *lat = ipcp_get_lattice (info, i);
|
2010-08-05 15:23:07 +02:00
|
|
|
if ((ipcp_lat_is_insertable (lat)
|
2008-08-24 22:09:32 +02:00
|
|
|
/* Do not count obviously unused arguments. */
|
2010-08-05 15:23:07 +02:00
|
|
|
&& ipa_is_param_used (info, i))
|
|
|
|
|| (!ipa_param_cannot_devirtualize_p (info, i)
|
|
|
|
&& !ipa_param_types_vec_empty (info, i)))
|
2008-08-24 22:09:32 +02:00
|
|
|
const_param++;
|
|
|
|
}
|
|
|
|
return const_param;
|
|
|
|
}
|
|
|
|
|
2010-08-05 15:30:14 +02:00
|
|
|
/* Given that a formal parameter of NODE given by INDEX is known to be constant
|
|
|
|
CST, try to find any indirect edges that can be made direct and make them
|
|
|
|
so. Note that INDEX is the number the parameter at the time of analyzing
|
|
|
|
parameter uses and parameter removals should not be considered for it. (In
|
|
|
|
fact, the parameter itself has just been removed.) */
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipcp_discover_new_direct_edges (struct cgraph_node *node, int index, tree cst)
|
|
|
|
{
|
|
|
|
struct cgraph_edge *ie, *next_ie;
|
|
|
|
|
|
|
|
for (ie = node->indirect_calls; ie; ie = next_ie)
|
|
|
|
{
|
|
|
|
struct cgraph_indirect_call_info *ici = ie->indirect_info;
|
|
|
|
|
|
|
|
next_ie = ie->next_callee;
|
2010-12-22 13:56:54 +01:00
|
|
|
if (ici->param_index != index
|
|
|
|
|| ici->polymorphic)
|
2010-08-05 15:30:14 +02:00
|
|
|
continue;
|
|
|
|
|
2010-12-22 13:56:54 +01:00
|
|
|
ipa_make_edge_direct_to_target (ie, cst, NULL_TREE);
|
2010-08-05 15:30:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
/* Propagate the constant parameters found by ipcp_iterate_stage()
|
|
|
|
to the function's code. */
|
|
|
|
static void
|
|
|
|
ipcp_insert_stage (void)
|
|
|
|
{
|
|
|
|
struct cgraph_node *node, *node1 = NULL;
|
2008-08-24 22:09:32 +02:00
|
|
|
int i;
|
2007-01-28 14:01:53 +01:00
|
|
|
VEC (cgraph_edge_p, heap) * redirect_callers;
|
2009-05-08 21:19:51 +02:00
|
|
|
VEC (ipa_replace_map_p,gc)* replace_trees;
|
2005-08-01 09:26:30 +02:00
|
|
|
int node_callers, count;
|
|
|
|
tree parm_tree;
|
|
|
|
struct ipa_replace_map *replace_param;
|
2008-08-24 22:09:32 +02:00
|
|
|
fibheap_t heap;
|
2009-05-08 21:19:51 +02:00
|
|
|
long overall_size = 0, new_size = 0;
|
|
|
|
long max_new_size;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2008-07-17 15:23:32 +02:00
|
|
|
ipa_check_create_node_params ();
|
|
|
|
ipa_check_create_edge_args ();
|
2008-08-29 18:41:35 +02:00
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "\nIPA insert stage:\n\n");
|
2008-07-17 15:23:32 +02:00
|
|
|
|
2008-08-24 22:09:32 +02:00
|
|
|
dead_nodes = BITMAP_ALLOC (NULL);
|
|
|
|
|
|
|
|
for (node = cgraph_nodes; node; node = node->next)
|
|
|
|
if (node->analyzed)
|
|
|
|
{
|
|
|
|
if (node->count > max_count)
|
|
|
|
max_count = node->count;
|
cgraph.c (dump_cgraph_node): Do not dump inline summaries.
* cgraph.c (dump_cgraph_node): Do not dump inline summaries.
* cgraph.h (struct inline_summary): Move to ipa-inline.h
(cgraph_local_info): Remove inline_summary.
* ipa-cp.c: Include ipa-inline.h.
(ipcp_cloning_candidate_p, ipcp_estimate_growth,
ipcp_estimate_cloning_cost, ipcp_insert_stage): Use inline_summary
accesor.
* lto-cgraph.c (lto_output_node): Do not stream inline summary.
(input_overwrite_node): Do not set inline summary.
(input_node): Do not stream inline summary.
* ipa-inline.c (cgraph_decide_inlining): Dump inline summaries.
(cgraph_decide_inlining_incrementally): Do not try to estimate overall
growth; we do not have inline parameters computed for that anyway.
(cgraph_early_inlining): After inlining compute call_stmt_sizes.
* ipa-inline.h (struct inline_summary): Move here from ipa-inline.h
(inline_summary_t): New type and VECtor.
(debug_inline_summary, dump_inline_summaries): Declare.
(inline_summary): Use VOCtor.
(estimate_edge_growth): Kill hack computing call stmt size directly.
* lto-section-in.c (lto_section_name): Add inline section.
* ipa-inline-analysis.c: Include lto-streamer.h
(node_removal_hook_holder, node_duplication_hook_holder): New holders
(inline_node_removal_hook, inline_node_duplication_hook): New functions.
(inline_summary_vec): Define.
(inline_summary_alloc, dump_inline_summary, debug_inline_summary,
dump_inline_summaries): New functions.
(estimate_function_body_sizes): Properly compute size/time of outgoing calls.
(compute_inline_parameters): Alloc inline_summary; do not compute size/time
of incomming calls.
(estimate_edge_time): Avoid missing time summary hack.
(inline_read_summary): Read inline summary info.
(inline_write_summary): Write inline summary info.
(inline_free_summary): Free all hooks and inline summary vector.
* lto-streamer.h: Add LTO_section_inline_summary section.
* Makefile.in (ipa-cp.o, ipa-inline-analysis.o): Update dependencies.
* ipa.c (cgraph_remove_unreachable_nodes): Fix dump file formating.
* lto.c: Include ipa-inline.h
(add_cgraph_node_to_partition, undo_partition): Use inline_summary accessor.
(ipa_node_duplication_hook): Fix declaration.
* Make-lang.in (lto.o): Update dependencies.
From-SVN: r172430
2011-04-14 15:26:44 +02:00
|
|
|
overall_size += inline_summary (node)->self_size;
|
2008-08-24 22:09:32 +02:00
|
|
|
}
|
|
|
|
|
2009-05-08 21:19:51 +02:00
|
|
|
max_new_size = overall_size;
|
|
|
|
if (max_new_size < PARAM_VALUE (PARAM_LARGE_UNIT_INSNS))
|
|
|
|
max_new_size = PARAM_VALUE (PARAM_LARGE_UNIT_INSNS);
|
|
|
|
max_new_size = max_new_size * PARAM_VALUE (PARAM_IPCP_UNIT_GROWTH) / 100 + 1;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2010-08-05 15:23:07 +02:00
|
|
|
/* First collect all functions we proved to have constant arguments to
|
|
|
|
heap. */
|
2008-08-24 22:09:32 +02:00
|
|
|
heap = fibheap_new ();
|
2005-08-01 09:26:30 +02:00
|
|
|
for (node = cgraph_nodes; node; node = node->next)
|
|
|
|
{
|
2008-07-17 15:23:32 +02:00
|
|
|
struct ipa_node_params *info;
|
|
|
|
/* Propagation of the constant is forbidden in certain conditions. */
|
2008-08-29 13:31:40 +02:00
|
|
|
if (!node->analyzed || !ipcp_node_modifiable_p (node))
|
2008-07-17 15:23:32 +02:00
|
|
|
continue;
|
|
|
|
info = IPA_NODE_REF (node);
|
|
|
|
if (ipa_is_called_with_var_arguments (info))
|
2005-08-01 09:26:30 +02:00
|
|
|
continue;
|
2008-08-24 22:09:32 +02:00
|
|
|
if (ipcp_const_param_count (node))
|
2010-08-05 15:23:07 +02:00
|
|
|
node->aux = fibheap_insert (heap, ipcp_estimate_cloning_cost (node),
|
|
|
|
node);
|
2008-08-24 22:09:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Now clone in priority order until code size growth limits are met or
|
|
|
|
heap is emptied. */
|
|
|
|
while (!fibheap_empty (heap))
|
|
|
|
{
|
|
|
|
struct ipa_node_params *info;
|
|
|
|
int growth = 0;
|
2008-08-29 13:31:40 +02:00
|
|
|
bitmap args_to_skip;
|
2008-09-22 06:24:28 +02:00
|
|
|
struct cgraph_edge *cs;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
|
|
|
node = (struct cgraph_node *)fibheap_extract_min (heap);
|
|
|
|
node->aux = NULL;
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "considering function %s\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
|
2008-08-31 18:45:05 +02:00
|
|
|
growth = ipcp_estimate_growth (node);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2009-05-08 21:19:51 +02:00
|
|
|
if (new_size + growth > max_new_size)
|
2008-08-24 22:09:32 +02:00
|
|
|
break;
|
|
|
|
if (growth
|
loop-unswitch.c (unswitch_single_loop): Use optimize_loop_for_speed_p.
* loop-unswitch.c (unswitch_single_loop): Use optimize_loop_for_speed_p.
* tree-ssa-threadupdate.c (mark_threaded_blocks): Use optimize_function_for_size_p.
* tracer.c (ignore_bb_p): Use optimize_bb_for_size_p.
* postreload-gcse.c (eliminate_partially_redundant_load): Use optimize_bb_for_size_p.
* value-prof.c (gimple_divmod_fixed_value_transform,
gimple_mod_pow2_value_transform, gimple_mod_subtract_transform,
gimple_stringops_transform): Use optimize_bb_for_size_p.
* ipa-cp.c (ipcp_insert_stage): Use optimize_function_for_size_p.
* final.c (compute_alignments): Use optimize_function_for_size_p.
* builtins.c (fold_builtin_cabs): Use optimize_function_for_speed_p.
(fold_builtin_strcpy, fold_builtin_fputs): Use
optimize_function_for_size_p.
* fold-const.c (tree_swap_operands_p): Use optimize_function_for_size_p.
* recog.c (relax_delay_slots): Likewise.
* tree-ssa-math-opts.c (replace_reciprocal): Use optimize_bb_for_speed_p.
(execute_cse_reciprocals): Use optimize_bb_for_size_p.
* ipa-inline.c (cgraph_decide_recursive_inlining): Use
optimize_function_for_size_p.
(cgraph_decide_inlining_of_small_function): Use
optimize_function_for_size_p.
* global.c (find_reg): Use optimize_function_for_size_p.
* opts.c (decode_options): Do not clear flag_tree_ch, flag_inline_functions,
flag_unswitch_loops, flag_unroll_loops, flag_unroll_all_loops and
flag_prefetch_loop_arrays. Those can work it out from profile.
* tree-ssa-loop-ivcanon.c (tree_unroll_loops_completely): Use
optimize_loop_for_speed_p.
* predict.c (optimize_bb_for_size_p, optimize_bb_for_speed_p): Constify
argument.
(optimize_loop_nest_for_size_p, optimize_loop_nest_for_speed_p): New.
* tree-parloops.c (parallelize_loops): Use optimize_loop_for_size_p.
* tree-eh.c (decide_copy_try_finally): Use optimize_function_for_size_p.
* local-alloc.c (block_alloc): Pass BB pointer.
(find_free_reg): Add BB pointer, use optimize_bb_for_size_p.
* gcse.c (gcse_main): Use optimize_function_for_size_p.
* loop-unroll.c (decide_unrolling_and_peeling): Use optimize_loop_for_size_p.
(decide_peel_completely): Likewise.
* tree-vect-analyze.c (vect_mark_for_runtime_alias_test): Use
optimize_loop_for_size_p.
(vect_enhance_data_refs_alignment): Likewise.
* tree-ssa-coalesce.c (coalesce_cost): Add optimize_for_size argument.
(coalesce_cost_bb, coalesce_cost_edge, create_outofssa_var_map): Update call.
* cfgcleanup.c (outgoing_edges_match): Use optimize_bb_for_speed_p.
(try_crossjump_bb): Use optimize_bb_for_size_p.
* tree-ssa-loop-prefetch.c (loop_prefetch_arrays): Use
optimize_loop_for_speed_p.
* bb-reorder.c (find_traces_1_round): Likewise.
(copy_bb): Use optimize_bb_for_speed_p.
(duplicate_computed_gotos): Likewise.
* basic-block.h (optimize_loop_nest_for_size_p,
optimize_loop_nest_for_speed_p): New.
* stmt.c (expand_case): Use optimize_insn_for_size_p.
From-SVN: r139760
2008-08-29 12:35:57 +02:00
|
|
|
&& optimize_function_for_size_p (DECL_STRUCT_FUNCTION (node->decl)))
|
2008-08-24 22:09:32 +02:00
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Not versioning, cold code would grow");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
info = IPA_NODE_REF (node);
|
2008-05-06 16:15:18 +02:00
|
|
|
count = ipa_get_param_count (info);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2009-05-08 21:19:51 +02:00
|
|
|
replace_trees = VEC_alloc (ipa_replace_map_p, gc, 1);
|
2011-01-26 15:06:20 +01:00
|
|
|
|
|
|
|
if (node->local.can_change_signature)
|
|
|
|
args_to_skip = BITMAP_GGC_ALLOC ();
|
|
|
|
else
|
|
|
|
args_to_skip = NULL;
|
2005-08-01 09:26:30 +02:00
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
ipa-prop.h (struct ipa_param_flags): Removed.
2008-09-11 Martin Jambor <mjambor@suse.cz>
* ipa-prop.h (struct ipa_param_flags): Removed.
(struct ipa_param_descriptor): New structure.
(struct ipa_node_params): ipcp_lattices, param_decls and
param_flags moved to ipa_param_description.
(ipa_get_ith_param): Renamed to ipa_get_param, changed to access
descriptors. Renamed all users.
(ipa_is_ith_param_modified): Renamed to ipa_is_param_modified,
changed to access descriptors. Renamed all users.
(ipa_is_ith_param_called): Renamed to ipa_is_param_called, changed
to access descriptors. Renamed all users.
* ipa-cp.c (ipcp_init_cloned_node): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
(ipcp_analyze_node): Likewise.
(ipcp_get_ith_lattice): Renamed to ipcp_get_lattice, changed to access
descriptors. Renamed all users.
(ipcp_initialize_node_lattices): Remove allocation.
* ipa-inline.c (inline_indirect_intraprocedural_analysis): Call
ipa_initialize_node_params instead of ipa_count_formal_params and
ipa_create_param_decls_array.
* ipa-prop.c (ipa_create_param_decls_array): Renamed to
ipa_populate_param_decls, made static, added parameter info,
renamed mt to node, removed allocation, changed to use
descriptors.
(ipa_count_formal_params): Made static, added parameter info,
renamed mt to node.
(ipa_initialize_node_params): New function.
(ipa_check_stmt_modifications): Changed to use descriptors.
(ipa_detect_param_modifications): Removed allocation, changed to
use descriptors.
(ipa_note_param_call): Changed to use descriptors.
(ipa_analyze_params_uses): Removed allocation.
(ipa_free_node_params_substructures): Changed to use descriptors.
(ipa_edge_duplication_hook): Use the unused attribute.
(ipa_node_duplication_hook): Use the unused attribute, changed to
use descriptors, changed to duplicate descriptors.
* ipa-inline.c (cgraph_mark_inline_edge): New parameter new_edges,
changed all callers. Call ipa_propagate_indirect_call_infos if doing
indirect inlining. Made static.
(cgraph_decide_inlining): Freeing ipa-prop structures after inlining
functions called only once.
(cgraph_decide_recursive_inlining): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining_of_small_functions): Don't call
ipa_propagate_indirect_call_infos, pass new_edges to
cgraph_mark_inline_edge instead.
(cgraph_decide_inlining): Don't call
ipa_propagate_indirect_call_infos.
* ipa-prop.c: Check that vectors are allocated.
* ipa-inline.c (cgraph_mark_inline_edge): Returns boolean, true
iff a new cgraph edges have been created.
(cgraph_decide_inlining): New variable redo_always_inline.
Flattening and always_inlining loop until callgraph stabilizes.
* ipa-prop.c (update_call_notes_after_inlining): Returns boolean,
true iff new cgraph edges have been created.
(propagate_info_to_inlined_callees): Likewise.
(ipa_propagate_indirect_call_infos): Likewise.
From-SVN: r140293
2008-09-11 19:03:23 +02:00
|
|
|
struct ipcp_lattice *lat = ipcp_get_lattice (info, i);
|
|
|
|
parm_tree = ipa_get_param (info, i);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2008-08-29 13:31:40 +02:00
|
|
|
/* We can proactively remove obviously unused arguments. */
|
2011-01-26 15:06:20 +01:00
|
|
|
if (!ipa_is_param_used (info, i))
|
2008-08-29 13:31:40 +02:00
|
|
|
{
|
2011-01-26 15:06:20 +01:00
|
|
|
if (args_to_skip)
|
|
|
|
bitmap_set_bit (args_to_skip, i);
|
2008-08-29 13:31:40 +02:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lat->type == IPA_CONST_VALUE)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
replace_param =
|
2008-08-24 00:25:20 +02:00
|
|
|
ipcp_create_replace_map (parm_tree, lat);
|
2011-03-05 00:07:20 +01:00
|
|
|
if (replace_param == NULL)
|
|
|
|
break;
|
2009-05-08 21:19:51 +02:00
|
|
|
VEC_safe_push (ipa_replace_map_p, gc, replace_trees, replace_param);
|
2011-01-26 15:06:20 +01:00
|
|
|
if (args_to_skip)
|
|
|
|
bitmap_set_bit (args_to_skip, i);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
}
|
2011-03-05 00:07:20 +01:00
|
|
|
if (i < count)
|
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "Not versioning, some parameters couldn't be replaced");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
new_size += growth;
|
|
|
|
|
|
|
|
/* Look if original function becomes dead after cloning. */
|
|
|
|
for (cs = node->callers; cs != NULL; cs = cs->next_caller)
|
|
|
|
if (cs->caller == node || ipcp_need_redirect_p (cs))
|
|
|
|
break;
|
|
|
|
if (!cs && cgraph_will_be_removed_from_program_if_no_direct_calls (node))
|
|
|
|
bitmap_set_bit (dead_nodes, node->uid);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
/* Compute how many callers node has. */
|
|
|
|
node_callers = 0;
|
|
|
|
for (cs = node->callers; cs != NULL; cs = cs->next_caller)
|
|
|
|
node_callers++;
|
2006-04-17 14:45:25 +02:00
|
|
|
redirect_callers = VEC_alloc (cgraph_edge_p, heap, node_callers);
|
2005-08-01 09:26:30 +02:00
|
|
|
for (cs = node->callers; cs != NULL; cs = cs->next_caller)
|
2010-08-05 15:30:14 +02:00
|
|
|
if (!cs->indirect_inlining_edge)
|
|
|
|
VEC_quick_push (cgraph_edge_p, redirect_callers, cs);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
/* Redirecting all the callers of the node to the
|
|
|
|
new versioned node. */
|
|
|
|
node1 =
|
2009-05-08 21:19:51 +02:00
|
|
|
cgraph_create_virtual_clone (node, redirect_callers, replace_trees,
|
2010-05-29 20:04:02 +02:00
|
|
|
args_to_skip, "constprop");
|
2009-05-08 21:19:51 +02:00
|
|
|
args_to_skip = NULL;
|
2006-04-17 14:45:25 +02:00
|
|
|
VEC_free (cgraph_edge_p, heap, redirect_callers);
|
2009-05-08 21:19:51 +02:00
|
|
|
replace_trees = NULL;
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
if (node1 == NULL)
|
|
|
|
continue;
|
2010-08-05 15:23:07 +02:00
|
|
|
ipcp_process_devirtualization_opportunities (node1);
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
if (dump_file)
|
2008-08-24 22:09:32 +02:00
|
|
|
fprintf (dump_file, "versioned function %s with growth %i, overall %i\n",
|
2009-05-08 21:19:51 +02:00
|
|
|
cgraph_node_name (node), (int)growth, (int)new_size);
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_init_cloned_node (node, node1);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2010-08-05 15:30:14 +02:00
|
|
|
info = IPA_NODE_REF (node);
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
struct ipcp_lattice *lat = ipcp_get_lattice (info, i);
|
|
|
|
if (lat->type == IPA_CONST_VALUE)
|
|
|
|
ipcp_discover_new_direct_edges (node1, i, lat->constant);
|
|
|
|
}
|
2008-08-21 17:26:59 +02:00
|
|
|
|
2007-01-28 14:01:53 +01:00
|
|
|
if (dump_file)
|
|
|
|
dump_function_to_file (node1->decl, dump_file, dump_flags);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
|
|
|
for (cs = node->callees; cs; cs = cs->next_callee)
|
|
|
|
if (cs->callee->aux)
|
|
|
|
{
|
|
|
|
fibheap_delete_node (heap, (fibnode_t) cs->callee->aux);
|
|
|
|
cs->callee->aux = fibheap_insert (heap,
|
|
|
|
ipcp_estimate_cloning_cost (cs->callee),
|
|
|
|
cs->callee);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
while (!fibheap_empty (heap))
|
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "skipping function %s\n",
|
|
|
|
cgraph_node_name (node));
|
|
|
|
node = (struct cgraph_node *) fibheap_extract_min (heap);
|
|
|
|
node->aux = NULL;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2008-08-24 22:09:32 +02:00
|
|
|
fibheap_delete (heap);
|
|
|
|
BITMAP_FREE (dead_nodes);
|
2005-08-01 09:26:30 +02:00
|
|
|
ipcp_update_callgraph ();
|
|
|
|
ipcp_update_profiling ();
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The IPCP driver. */
|
2007-01-28 14:01:53 +01:00
|
|
|
static unsigned int
|
2005-08-01 09:26:30 +02:00
|
|
|
ipcp_driver (void)
|
|
|
|
{
|
2008-08-29 18:41:35 +02:00
|
|
|
cgraph_remove_unreachable_nodes (true,dump_file);
|
2005-08-01 09:26:30 +02:00
|
|
|
if (dump_file)
|
|
|
|
{
|
2008-08-29 18:41:35 +02:00
|
|
|
fprintf (dump_file, "\nIPA structures before propagation:\n");
|
|
|
|
if (dump_flags & TDF_DETAILS)
|
|
|
|
ipa_print_all_params (dump_file);
|
|
|
|
ipa_print_all_jump_functions (dump_file);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2011-04-11 16:25:55 +02:00
|
|
|
ipa_check_create_node_params ();
|
|
|
|
ipa_check_create_edge_args ();
|
2008-08-29 18:41:35 +02:00
|
|
|
/* 2. Do the interprocedural propagation. */
|
|
|
|
ipcp_iterate_stage ();
|
2005-08-01 09:26:30 +02:00
|
|
|
/* 3. Insert the constants found to the functions. */
|
|
|
|
ipcp_insert_stage ();
|
2008-08-29 18:41:35 +02:00
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
fprintf (dump_file, "\nProfiling info after insert stage:\n");
|
2008-05-06 16:15:18 +02:00
|
|
|
ipcp_print_profile_data (dump_file);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
/* Free all IPCP structures. */
|
2010-04-28 16:05:54 +02:00
|
|
|
ipa_free_all_structures_after_ipa_cp ();
|
2005-08-01 09:26:30 +02:00
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "\nIPA constant propagation end\n");
|
2006-03-02 20:00:11 +01:00
|
|
|
return 0;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2010-08-05 15:23:07 +02:00
|
|
|
/* Initialization and computation of IPCP data structures. This is the initial
|
|
|
|
intraprocedural analysis of functions, which gathers information to be
|
|
|
|
propagated later on. */
|
|
|
|
|
2008-08-21 17:26:59 +02:00
|
|
|
static void
|
|
|
|
ipcp_generate_summary (void)
|
|
|
|
{
|
2010-08-05 15:23:07 +02:00
|
|
|
struct cgraph_node *node;
|
|
|
|
|
2008-08-21 17:26:59 +02:00
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "\nIPA constant propagation start:\n");
|
|
|
|
ipa_register_cgraph_hooks ();
|
2010-08-05 15:23:07 +02:00
|
|
|
|
|
|
|
for (node = cgraph_nodes; node; node = node->next)
|
|
|
|
if (node->analyzed)
|
|
|
|
{
|
|
|
|
/* Unreachable nodes should have been eliminated before ipcp. */
|
|
|
|
gcc_assert (node->needed || node->reachable);
|
|
|
|
|
cgraphbuild.c: Include ipa-inline.h.
* cgraphbuild.c: Include ipa-inline.h.
(reset_inline_failed): Use initialize_inline_failed.
* cgraph.c: Include ipa-inline.h.
(cgraph_create_node_1): Do not initialize estimated_growth.
(initialize_inline_failed): More to ipa-inline-analysis.c
(dump_cgraph_node): Do not dump inline flags.
* cgraph.h (cgraph_local_info): Remove inlineable, versionable
and disregard_inline_limits flags.
(cgrpah_global_info): Remove estimated_stack_size, stack_frame_offset,
time, size, estimated_growth.
* ipa-cp.c (ipcp_versionable_function_p, ipcp_generate_summary): Update.
* cgraphunit.c (cgraph_decide_is_function_needed): Use
DECL_DISREGARD_INLINE_LIMITS.
(cgraph_analyze_function): Do not initialize
node->local.disregard_inline_limits.
* lto-cgraph.c (lto_output_node, input_overwrite_node): Do not stream
inlinable, versionable and disregard_inline_limits.
* ipa-inline.c (cgraph_clone_inlined_nodes, cgraph_mark_inline_edge,
cgraph_check_inline_limits, cgraph_default_inline_p, cgraph_edge_badness,
update_caller_keys, update_callee_keys, add_new_edges_to_heap): Update.
(cgraph_decide_inlining_of_small_function): Update; set CIF_FUNCTION_NOT_INLINABLE
for uninlinable functions.
(cgraph_decide_inlining, cgraph_edge_early_inlinable_p,
cgraph_decide_inlining_incrementally): Update.
* ipa-inline.h (inline_summary): Add inlinable, versionable, disregard_inline_limits,
estimated_stack_size, stack_frame_offset, time, size and estimated_growth
parameters.
(estimate_edge_growth): Update.
(initialize_inline_failed): Declare.
* ipa-split.c: Include ipa-inline.h
(execute_split_functions): Update.
* ipa.c (cgraph_postorder): Use DECL_DISREGARD_INLINE_LIMITS.
(cgraph_remove_unreachable_nodes): Do not clear inlinable flag.
(record_cdtor_fn): Use DECL_DISREGARD_INLINE_LIMITS.
* ipa-inline-analysis.c (inline_node_removal_hook): Update; set
estimated_growth to INT_MIN.
(inline_node_duplication_hook): Likewise.
(dump_inline_summary): Dump new fields.
(compute_inline_parameters): Update.
(estimate_edge_time, estimate_time_after_inlining,
estimate_size_after_inlining, estimate_growth, inline_read_summary,
inline_write_summary):
(initialize_inline_failed): Move here from cgraph.c.
* tree-sra.c: Include ipa-inline.h.
(ipa_sra_preliminary_function_checks): Update.
* lto/lto.c (lto_balanced_map): Update.
Update.
* Makefile.in: (cgraph.o, cgraphbuild.o): Add dependency on
ipa-inline.h
From-SVN: r172581
2011-04-16 11:13:08 +02:00
|
|
|
inline_summary (node)->versionable = tree_versionable_function_p (node->decl);
|
2010-08-05 15:23:07 +02:00
|
|
|
ipa_analyze_node (node);
|
|
|
|
}
|
2008-08-21 17:26:59 +02:00
|
|
|
}
|
|
|
|
|
ipa-cp.c (ipcp_write_summary, [...]): New functions.
* ipa-cp.c (ipcp_write_summary, ipcp_read_summary): New functions.
(pass_ipa_cp): Register them.
(ipcp_init_stage): Analyze all functions for whopr/lto.
(ipcp_propagate_stage): Skip external calls.
(ipcp_iterate_stage): Call ipa_update_after_lto_read if needed.
* ipa-reference.c (write_node_summary_p): Fix thinko about availability.
* cgraphunit.c (ipa_passes): When in lto, ne er produce new summaries;
when in ltrans, skip executing of ipa passes since everything should've
been done.
* ipa-inline.c (cgraph_decide_inlining): Remove FIXMEs.
(inline_generate_summary): Likewise.
(inline_read_summary): New function.
(inline_write_summary): New function.
(pass_ipa_inline): Register new hooks.
* ipa-prop.c: Inlcude lto-streamer.h
(ipa_edge_args_vector): Update declaration.
(ipa_count_arguments, ipa_compute_jump_functions,
ipa_free_edge_args_substructures): Move ipa_edge_args_vector into ggc.
(ipa_write_jump_function, ipa_read_jump_function, ipa_write_node_info,
ipa_read_node_info): New static functions.
(ipa_prop_write_jump_functions, ipa_prop_read_jump_functions): Update.
(duplicate_array): Use xmalloc.
(duplicate_ggc_array): New.
(ipa_edge_duplication_hook): Use it.
(ipa_update_after_lto_read): New function.
* ipa-prop.h (ipa_prop_write_jump_functions,
ipa_prop_read_jump_functions): Declare.
(ipa_pass_through_data, ipa_ancestor_jf_data, ipa_member_ptr_cst,
jump_func_value, ipa_member_ptr_cst, ipa_edge_args): Add GTY markers.
(ipa_edge_args_vector): Move into GGC.
(ipa_check_create_edge_args): Update.
(ipa_update_after_lto_read): New.
* passes.c (ipa_write_summaries_1): When in wpa, do not write summaries.
(ipa_read_summaries): When in ltrans, so not read summaries.
* lto-streamer.c (lto_get_section_name): Add LTO_section_jump_functions.
* lto-streamer.h (LTO_section_jump_functions): New section.
(produce_asm): Declare.
* lto-cgraph.c (output_cgraph): Output edges in reverse order.
* lto-streamer-out.c (produce_asm): Export.
* lto-streamer-in.c: Include tree-pass.h
(input_function): Free dominance info when done.
(lto_read_body): Push ipa_inline in ltrans stage.
* gengtype.c (open_base_files): Add ipa-prop.h into includes.
* Makefile.in (GTFILES): Add ipa-prop.h
* lto.c (lto_fixup_jump_functions): New function.
(lto_fixup_decls): Use it.
From-SVN: r153449
2009-10-22 12:02:29 +02:00
|
|
|
/* Write ipcp summary for nodes in SET. */
|
|
|
|
static void
|
* lto-symtab.c (lto_symtab_entry_def) Add vnode.
(lto_varpool_replace_node): New.
(lto_symtab_resolve_symbols): Resolve varpool nodes.
(lto_symtab_merge_decls_1): Prefer decls with varpool node.
(lto_symtab_merge_cgraph_nodes_1): Merge varpools.
* cgraph.h (varpool_node_ptr): New type.
(varpool_node_ptr): New vector.
(varpool_node_set_def): New structure.
(varpool_node_set): New type.
(varpool_node_set): New vector.
(varpool_node_set_element_def): New structure.
(varpool_node_set_element, const_varpool_node_set_element): New types.
(varpool_node_set_iterator): New type.
(varpool_node): Add prev pointers, add used_from_other_partition,
in_other_partition.
(varpool_node_set_new, varpool_node_set_find, varpool_node_set_add,
varpool_node_set_remove, dump_varpool_node_set, debug_varpool_node_set,
varpool_get_node, varpool_remove_node): Declare.
(vsi_end_p, vsi_next, vsi_node, vsi_start, varpool_node_in_set_p,
varpool_node_set_size): New inlines.
* cgraph.c (dump_cgraph_node): Dump asm names of aliases.
* tree-pass.h (varpool_node_set_def): Forward declare.
(ipa_opt_pass_d): Summary writting takes vnode sets too.
(ipa_write_optimization_summaries): Update prototype.
* ipa-cp.c (ipcp_write_summary): Update.
* ipa-reference.c (ipa_reference_write_summary): Update.
* lto-cgraph.c (lto_output_varpool_node): New static function.
(output_varpool): New function.
(input_varpool_node): New static function.
(input_varpool_1): New function.
(input_cgraph): Input varpool.
* ipa-pure-const.c (pure_const_write_summary): Update.
* lto-streamer-out.c (lto_output): Update, output varpool too.
(write_global_stream): Kill WPA hack.
(produce_asm_for_decls): Update.
(output_alias_pair_p): Handle variables.
(output_unreferenced_globals): Output only needed partition of varpool.
* ipa-inline.c (inline_write_summary): Update.
* lto-streamer-in.c (lto_input_tree_ref, lto_input_tree): Do not build cgraph.
* lto-section-in.c (lto_section_name): Add varpool and jump funcs.
* ipa.c (hash_varpool_node_set_element, eq_varpool_node_set_element,
varpool_node_set_new, varpool_node_set_add,
varpool_node_set_remove, varpool_node_set_find, dump_varpool_node_set,
debug_varpool_node_set): New functions.
* passes.c (rest_of_decl_compilation): when in LTO do not finalize.
(execute_one_pass): Process new decls too.
(ipa_write_summaries_2): Pass around vsets.
(ipa_write_summaries_1): Likewise.
(ipa_write_summaries): Build vset; be more selective about cgraph nodes
to add.
(ipa_write_optimization_summaries_1): Pass around vsets.
(ipa_write_optimization_summaries): Likewise.
* varpool.c (varpool_get_node): New.
(varpool_node): Update doubly linked lists.
(varpool_remove_node): New.
(dump_varpool_node): More dumping.
(varpool_enqueue_needed_node): Update doubly linked lists.
(decide_is_variable_needed): Kill ltrans hack.
(varpool_finalize_decl): Kill lto hack.
(varpool_assemble_decl): Skip decls in other partitions.
(varpool_assemble_pending_decls): Update doubly linkes lists.
(varpool_empty_needed_queue): Likewise.
(varpool_extra_name_alias): Likewise.
* lto-streamer.c (lto_get_section_name): Add vars section.
* lto-streamer.h (lto_section_type): Update.
(output_varpool, input_varpool): Declare.
* lto.c (lto_varpool_node_sets): New.
(lto_1_to_1_map): Partition varpool too.
(globalize_context_t, globalize_cross_file_statics,
lto_scan_statics_in_ref_table, lto_scan_statics_in_cgraph_node,
lto_scan_statics_in_remaining_global_vars): Remove.
(lto_promote_cross_file_statics): Rewrite.
(get_filename_for_set): Take vset argument.
(lto_wpa_write_files): Pass around vsets.
From-SVN: r158854
2010-04-29 09:10:38 +02:00
|
|
|
ipcp_write_summary (cgraph_node_set set,
|
|
|
|
varpool_node_set vset ATTRIBUTE_UNUSED)
|
ipa-cp.c (ipcp_write_summary, [...]): New functions.
* ipa-cp.c (ipcp_write_summary, ipcp_read_summary): New functions.
(pass_ipa_cp): Register them.
(ipcp_init_stage): Analyze all functions for whopr/lto.
(ipcp_propagate_stage): Skip external calls.
(ipcp_iterate_stage): Call ipa_update_after_lto_read if needed.
* ipa-reference.c (write_node_summary_p): Fix thinko about availability.
* cgraphunit.c (ipa_passes): When in lto, ne er produce new summaries;
when in ltrans, skip executing of ipa passes since everything should've
been done.
* ipa-inline.c (cgraph_decide_inlining): Remove FIXMEs.
(inline_generate_summary): Likewise.
(inline_read_summary): New function.
(inline_write_summary): New function.
(pass_ipa_inline): Register new hooks.
* ipa-prop.c: Inlcude lto-streamer.h
(ipa_edge_args_vector): Update declaration.
(ipa_count_arguments, ipa_compute_jump_functions,
ipa_free_edge_args_substructures): Move ipa_edge_args_vector into ggc.
(ipa_write_jump_function, ipa_read_jump_function, ipa_write_node_info,
ipa_read_node_info): New static functions.
(ipa_prop_write_jump_functions, ipa_prop_read_jump_functions): Update.
(duplicate_array): Use xmalloc.
(duplicate_ggc_array): New.
(ipa_edge_duplication_hook): Use it.
(ipa_update_after_lto_read): New function.
* ipa-prop.h (ipa_prop_write_jump_functions,
ipa_prop_read_jump_functions): Declare.
(ipa_pass_through_data, ipa_ancestor_jf_data, ipa_member_ptr_cst,
jump_func_value, ipa_member_ptr_cst, ipa_edge_args): Add GTY markers.
(ipa_edge_args_vector): Move into GGC.
(ipa_check_create_edge_args): Update.
(ipa_update_after_lto_read): New.
* passes.c (ipa_write_summaries_1): When in wpa, do not write summaries.
(ipa_read_summaries): When in ltrans, so not read summaries.
* lto-streamer.c (lto_get_section_name): Add LTO_section_jump_functions.
* lto-streamer.h (LTO_section_jump_functions): New section.
(produce_asm): Declare.
* lto-cgraph.c (output_cgraph): Output edges in reverse order.
* lto-streamer-out.c (produce_asm): Export.
* lto-streamer-in.c: Include tree-pass.h
(input_function): Free dominance info when done.
(lto_read_body): Push ipa_inline in ltrans stage.
* gengtype.c (open_base_files): Add ipa-prop.h into includes.
* Makefile.in (GTFILES): Add ipa-prop.h
* lto.c (lto_fixup_jump_functions): New function.
(lto_fixup_decls): Use it.
From-SVN: r153449
2009-10-22 12:02:29 +02:00
|
|
|
{
|
|
|
|
ipa_prop_write_jump_functions (set);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read ipcp summary. */
|
|
|
|
static void
|
|
|
|
ipcp_read_summary (void)
|
|
|
|
{
|
|
|
|
ipa_prop_read_jump_functions ();
|
|
|
|
}
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
/* Gate for IPCP optimization. */
|
|
|
|
static bool
|
|
|
|
cgraph_gate_cp (void)
|
|
|
|
{
|
2010-07-23 18:35:52 +02:00
|
|
|
/* FIXME: We should remove the optimize check after we ensure we never run
|
2011-02-11 16:16:46 +01:00
|
|
|
IPA passes when not optimizing. */
|
2010-07-23 18:35:52 +02:00
|
|
|
return flag_ipa_cp && optimize;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2009-05-16 08:54:11 +02:00
|
|
|
struct ipa_opt_pass_d pass_ipa_cp =
|
re PR other/35094 (RTL dump file letters hosed and partly undocumented)
* gcc.dg/20050811-2.c: Update dumping flags.
* gcc.dg/sms-2.c: Update dumping flags.
* gcc.dg/var-expand1.c: Update dumping flags.
* gcc.dg/var-expand3.c: Update dumping flags.
* gcc.dg/pr30957-1.c: Update dumping flags.
* gcc.dg/20050811-1.c: Update dumping flags.
* gcc.dg/cpp/cmdlne-dI-M.C: Do not xfail.
* gcc.dg/cpp/cmdlne-dM-M.C: Do not xfail.
PR other/35094
* toplev.c (decode_d_option): Handle all CPP flags.
* tree-vrp.c: Update tree_pass descriptors.
* regrename.c: Update tree_pass descriptors.
* fwprop.c: Update tree_pass descriptors.
* doc/invoke.texi: Remove documentation of dropped -d? flags.
* tree-into-ssa.c: Update tree_pass descriptors.
* tree-dump.c: Update tree_pass descriptors.
* tree-complex.c: Update tree_pass descriptors.
* tree-dump.h: Update tree_pass descriptors.
* see.c: Update tree_pass descriptors.
* cgraphbuild.c: Update tree_pass descriptors.
* tracer.c: Update tree_pass descriptors.
* tree-loop-distribution.c: Update tree_pass descriptors.
* cgraph.c: Update tree_pass descriptors.
* postreload-gcse.c: Update tree_pass descriptors.
* postreload.c: Update tree_pass descriptors.
* tree-ssa-loop-ch.c: Update tree_pass descriptors.
* tree-tailcall.c: Update tree_pass descriptors.
* tree-pass.h (tree_opt_pass): Rename to ...
(opt_pass) ... this one; add "type" field and remove letter field.
(gimple_opt_pass, rtl_opt_pass, simple_ipa_opt_pass): New.
(execute_pass_list, execute_ipa_pass_list, all_passes, all_ipa_passes,
all_lowering_passes): Update declaration.
* ipa-cp.c: Update tree_pass descriptors.
* final.c: Update tree_pass descriptors.
* omp-low.c: Update tree_pass descriptors.
* tree-ssa-dse.c: Update tree_pass descriptors.
* ipa-reference.c: Update tree_pass descriptors.
* tree-ssa-uncprop.c: Update tree_pass descriptors.
* auto-inc-dec.c: Update tree_pass descriptors.
* reorg.c: Update tree_pass descriptors.
* cgraphunit.c: Update tree_pass descriptors.
* tree-ssa-copyrename.c: Update tree_pass descriptors.
* tree-ssa-ccp.c: Update tree_pass descriptors.
* df-core.c: Update tree_pass descriptors.
* mode-switching.c: Update tree_pass descriptors.
* tree-nomudflap.c: Update tree_pass descriptors.
* modulo-sched.c: Update tree_pass descriptors.
* ipa-pure-const.c: Update tree_pass descriptors.
* cse.c: Update tree_pass descriptors.
* web.c: Update tree_pass descriptors.
* tree-stdarg.c: Update tree_pass descriptors.
* tree-ssa-math-opts.c: Update tree_pass descriptors.
* tree-ssa-dom.c: Update tree_pass descriptors.
* tree-nrv.c: Update tree_pass descriptors.
* tree-ssa-alias.c: Update tree_pass descriptors.
* loop-init.c: Update tree_pass descriptors.
* gimple-low.c: Update tree_pass descriptors.
* ipa-inline.c: Update tree_pass descriptors.
* tree-ssa-sink.c: Update tree_pass descriptors.
* global.c: Update tree_pass descriptors.
* ifcvt.c: Update tree_pass descriptors.
* jump.c: Update tree_pass descriptors.
* predict.c: Update tree_pass descriptors.
* tree-ssa-loop.c: Update tree_pass descriptors.
* recog.c: Update tree_pass descriptors.
* dse.c: Update tree_pass descriptors.
* tree-ssa-ifcombine.c: Update tree_pass descriptors.
* tree-eh.c: Update tree_pass descriptors.
* regmove.c: Update tree_pass descriptors.
* local-alloc.c
* function.c: Update tree_pass descriptors.
* tree-vectorizer.c: Update tree_pass descriptors.
* gcse.c: Update tree_pass descriptors.
* ipa-type-escape.c: Update tree_pass descriptors.
* tree-if-conv.c: Update tree_pass descriptors.
* init-regs.c: Update tree_pass descriptors.
* ipa.c: Update tree_pass descriptors.
* tree-ssa-phiopt.c: Update tree_pass descriptors.
* rtl-factoring.c: Update tree_pass descriptors.
* lower-subreg.c: Update tree_pass descriptors.
* bt-load.c: Update tree_pass descriptors.
* tree-dfa.c: Update tree_pass descriptors.
* except.c: Update tree_pass descriptors.
* emit-rtl.c: Update tree_pass descriptors.
* cfgexpand.c: Update tree_pass descriptors.
* tree-cfgcleanup.c: Update tree_pass descriptors.
* cfgcleanup.c: Update tree_pass descriptors.
* tree-ssa-pre.c: Update tree_pass descriptors.
* tree-sra.c: Update tree_pass descriptors.
* tree-mudflap.c: Update tree_pass descriptors.
* tree-ssa-copy.c: Update tree_pass descriptors.
* cfglayout.c: Update tree_pass descriptors.
* tree-ssa-forwprop.c: Update tree_pass descriptors.
* tree-ssa-dce.c: Update tree_pass descriptors.
* tree-ssa.c: Update tree_pass descriptors.
* regclass.c: Update tree_pass descriptors.
* integrate.c: Update tree_pass descriptors.
* tree-optimize.c: Update tree_pass descriptors.
* tree-ssa-phiprop.c: Update tree_pass descriptors.
* tree-object-size.c: Update tree_pass descriptors.
* combine.c: Update tree_pass descriptors.
* tree-outof-ssa.c: Update tree_pass descriptors.
* bb-reorder.c: Update tree_pass descriptors.
* stack-ptr-mod.c: Update tree_pass descriptors.
* var-tracking.c: Update tree_pass descriptors.
* tree-profile.c: Update tree_pass descriptors.
* tree-vect-generic.c: Update tree_pass descriptors.
* reg-stack.c: Update tree_pass descriptors.
* sched-rgn.c: Update tree_pass descriptors.
* tree-ssa-structalias.c: Update tree_pass descriptors.
* tree-cfg.c: Update tree_pass descriptors.
* passes.c (current_pass): Update declaration.
(finish_optimization_passes): Update.
(all_passes, all_ipa_passes, all_lowering_passes): Update declaration.
(register_one_dump_file, register_dump_files_1, next_pass_1):
Update arguments.
(init_optimization_passes): Update handling of new types.
(execute_one_pass, execute_pass_list, execute_ipa_pass_list): Update.
* ipa-struct-reorg.c: Update tree_pass descriptors.
* tree-ssa-reassoc.c: Update tree_pass descriptors.
* combine-stack-adj.c: Update tree_pass descriptors.
* cfgrtl.c: Update tree_pass descriptors.
* dce.c: Update tree_pass descriptors.
* tree-ssanames.c: Update tree_pass descriptors.
From-SVN: r133342
2008-03-19 12:22:40 +01:00
|
|
|
{
|
|
|
|
{
|
2008-08-21 17:26:59 +02:00
|
|
|
IPA_PASS,
|
2005-08-01 09:26:30 +02:00
|
|
|
"cp", /* name */
|
|
|
|
cgraph_gate_cp, /* gate */
|
|
|
|
ipcp_driver, /* execute */
|
|
|
|
NULL, /* sub */
|
|
|
|
NULL, /* next */
|
|
|
|
0, /* static_pass_number */
|
|
|
|
TV_IPA_CONSTANT_PROP, /* tv_id */
|
|
|
|
0, /* properties_required */
|
2009-04-03 22:15:40 +02:00
|
|
|
0, /* properties_provided */
|
2005-08-01 09:26:30 +02:00
|
|
|
0, /* properties_destroyed */
|
|
|
|
0, /* todo_flags_start */
|
2008-08-29 18:41:35 +02:00
|
|
|
TODO_dump_cgraph | TODO_dump_func |
|
2010-04-30 00:44:18 +02:00
|
|
|
TODO_remove_functions | TODO_ggc_collect /* todo_flags_finish */
|
2008-08-21 17:26:59 +02:00
|
|
|
},
|
|
|
|
ipcp_generate_summary, /* generate_summary */
|
ipa-cp.c (ipcp_write_summary, [...]): New functions.
* ipa-cp.c (ipcp_write_summary, ipcp_read_summary): New functions.
(pass_ipa_cp): Register them.
(ipcp_init_stage): Analyze all functions for whopr/lto.
(ipcp_propagate_stage): Skip external calls.
(ipcp_iterate_stage): Call ipa_update_after_lto_read if needed.
* ipa-reference.c (write_node_summary_p): Fix thinko about availability.
* cgraphunit.c (ipa_passes): When in lto, ne er produce new summaries;
when in ltrans, skip executing of ipa passes since everything should've
been done.
* ipa-inline.c (cgraph_decide_inlining): Remove FIXMEs.
(inline_generate_summary): Likewise.
(inline_read_summary): New function.
(inline_write_summary): New function.
(pass_ipa_inline): Register new hooks.
* ipa-prop.c: Inlcude lto-streamer.h
(ipa_edge_args_vector): Update declaration.
(ipa_count_arguments, ipa_compute_jump_functions,
ipa_free_edge_args_substructures): Move ipa_edge_args_vector into ggc.
(ipa_write_jump_function, ipa_read_jump_function, ipa_write_node_info,
ipa_read_node_info): New static functions.
(ipa_prop_write_jump_functions, ipa_prop_read_jump_functions): Update.
(duplicate_array): Use xmalloc.
(duplicate_ggc_array): New.
(ipa_edge_duplication_hook): Use it.
(ipa_update_after_lto_read): New function.
* ipa-prop.h (ipa_prop_write_jump_functions,
ipa_prop_read_jump_functions): Declare.
(ipa_pass_through_data, ipa_ancestor_jf_data, ipa_member_ptr_cst,
jump_func_value, ipa_member_ptr_cst, ipa_edge_args): Add GTY markers.
(ipa_edge_args_vector): Move into GGC.
(ipa_check_create_edge_args): Update.
(ipa_update_after_lto_read): New.
* passes.c (ipa_write_summaries_1): When in wpa, do not write summaries.
(ipa_read_summaries): When in ltrans, so not read summaries.
* lto-streamer.c (lto_get_section_name): Add LTO_section_jump_functions.
* lto-streamer.h (LTO_section_jump_functions): New section.
(produce_asm): Declare.
* lto-cgraph.c (output_cgraph): Output edges in reverse order.
* lto-streamer-out.c (produce_asm): Export.
* lto-streamer-in.c: Include tree-pass.h
(input_function): Free dominance info when done.
(lto_read_body): Push ipa_inline in ltrans stage.
* gengtype.c (open_base_files): Add ipa-prop.h into includes.
* Makefile.in (GTFILES): Add ipa-prop.h
* lto.c (lto_fixup_jump_functions): New function.
(lto_fixup_decls): Use it.
From-SVN: r153449
2009-10-22 12:02:29 +02:00
|
|
|
ipcp_write_summary, /* write_summary */
|
|
|
|
ipcp_read_summary, /* read_summary */
|
2010-04-21 19:44:03 +02:00
|
|
|
NULL, /* write_optimization_summary */
|
|
|
|
NULL, /* read_optimization_summary */
|
2010-04-28 16:05:54 +02:00
|
|
|
NULL, /* stmt_fixup */
|
2008-08-21 17:26:59 +02:00
|
|
|
0, /* TODOs */
|
|
|
|
NULL, /* function_transform */
|
|
|
|
NULL, /* variable_transform */
|
2005-08-01 09:26:30 +02:00
|
|
|
};
|