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.
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
Contributed by Razya Ladelsky <RAZYA@il.ibm.com> and Martin Jambor
|
|
|
|
<mjambor@suse.cz>
|
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
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Interprocedural constant propagation (IPA-CP).
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
The goal of this transformation is to
|
2008-05-06 16:15:18 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
1) discover functions which are always invoked with some arguments with the
|
|
|
|
same known constant values and modify the functions so that the
|
|
|
|
subsequent optimizations can take advantage of the knowledge, and
|
2008-05-06 16:15:18 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
2) partial specialization - create specialized versions of functions
|
|
|
|
transformed in this way if some parameters are known constants only in
|
|
|
|
certain contexts but the estimated tradeoff between speedup and cost size
|
|
|
|
is deemed good.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
The algorithm also propagates types and attempts to perform type based
|
|
|
|
devirtualization. Types are propagated much like constants.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
The algorithm basically consists of three stages. In the first, functions
|
|
|
|
are analyzed one at a time and jump functions are constructed for all known
|
|
|
|
call-sites. In the second phase, the pass propagates information from the
|
|
|
|
jump functions across the call to reveal what values are available at what
|
|
|
|
call sites, performs estimations of effects of known values on functions and
|
|
|
|
their callees, and finally decides what specialized extra versions should be
|
|
|
|
created. In the third, the special versions materialize and appropriate
|
|
|
|
calls are redirected.
|
2008-05-06 16:15:18 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
The algorithm used is to a certain extent based on "Interprocedural Constant
|
|
|
|
Propagation", by David Callahan, Keith D Cooper, Ken Kennedy, Linda Torczon,
|
|
|
|
Comp86, pg 152-161 and "A Methodology for Procedure Cloning" by Keith D
|
|
|
|
Cooper, Mary W. Hall, and Ken Kennedy.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
|
|
|
|
First stage - intraprocedural analysis
|
|
|
|
=======================================
|
2011-07-19 00:03:39 +02:00
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
This phase computes jump_function and modification flags.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
A jump function for a call-site represents the values passed as an actual
|
|
|
|
arguments of a given call-site. In principle, there are three types of
|
|
|
|
values:
|
|
|
|
|
|
|
|
Pass through - the caller's formal parameter is passed as an actual
|
|
|
|
argument, plus an operation on it can be performed.
|
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
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
All jump function types are described in detail in ipa-prop.h, together with
|
|
|
|
the data structures that represent them and methods of accessing them.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
ipcp_generate_summary() is the main function of the first stage.
|
2005-08-01 09:26:30 +02:00
|
|
|
|
|
|
|
Second stage - interprocedural analysis
|
|
|
|
========================================
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
This stage is itself divided into two phases. In the first, we propagate
|
|
|
|
known values over the call graph, in the second, we make cloning decisions.
|
|
|
|
It uses a different algorithm than the original Callahan's paper.
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
First, we traverse the functions topologically from callers to callees and,
|
|
|
|
for each strongly connected component (SCC), we propagate constants
|
|
|
|
according to previously computed jump functions. We also record what known
|
|
|
|
values depend on other known values and estimate local effects. Finally, we
|
|
|
|
propagate cumulative information about these effects from dependant values
|
|
|
|
to those on which they depend.
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
Second, we again traverse the call graph in the same topological order and
|
|
|
|
make clones for functions which we know are called with the same values in
|
|
|
|
all contexts and decide about extra specialized clones of functions just for
|
|
|
|
some contexts - these decisions are based on both local estimates and
|
|
|
|
cumulative estimates propagated from callees.
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
ipcp_propagate_stage() and ipcp_decision_stage() together constitute the
|
|
|
|
third stage.
|
|
|
|
|
|
|
|
Third phase - materialization of clones, call statement updates.
|
2005-08-01 09:26:30 +02:00
|
|
|
============================================
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
This stage is currently performed by call graph code (mainly in cgraphunit.c
|
|
|
|
and tree-inline.c) according to instructions inserted to the call graph by
|
|
|
|
the second stage. */
|
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"
|
2011-07-19 00:03:39 +02:00
|
|
|
#include "ipa-utils.h"
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_value;
|
2008-08-29 18:41:35 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Describes a particular source for an IPA-CP value. */
|
2008-08-29 18:41:35 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_value_source
|
|
|
|
{
|
|
|
|
/* The incoming edge that brought the value. */
|
|
|
|
struct cgraph_edge *cs;
|
|
|
|
/* If the jump function that resulted into his value was a pass-through or an
|
|
|
|
ancestor, this is the ipcp_value of the caller from which the described
|
|
|
|
value has been derived. Otherwise it is NULL. */
|
|
|
|
struct ipcp_value *val;
|
|
|
|
/* Next pointer in a linked list of sources of a value. */
|
|
|
|
struct ipcp_value_source *next;
|
|
|
|
/* If the jump function that resulted into his value was a pass-through or an
|
|
|
|
ancestor, this is the index of the parameter of the caller the jump
|
|
|
|
function references. */
|
|
|
|
int index;
|
|
|
|
};
|
2008-08-29 18:41:35 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Describes one particular value stored in struct ipcp_lattice. */
|
2008-08-29 18:41:35 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_value
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
/* The actual value for the given parameter. This is either an IPA invariant
|
|
|
|
or a TREE_BINFO describing a type that can be used for
|
|
|
|
devirtualization. */
|
|
|
|
tree value;
|
|
|
|
/* The list of sources from which this value originates. */
|
|
|
|
struct ipcp_value_source *sources;
|
|
|
|
/* Next pointers in a linked list of all values in a lattice. */
|
|
|
|
struct ipcp_value *next;
|
|
|
|
/* Next pointers in a linked list of values in a strongly connected component
|
|
|
|
of values. */
|
|
|
|
struct ipcp_value *scc_next;
|
|
|
|
/* Next pointers in a linked list of SCCs of values sorted topologically
|
|
|
|
according their sources. */
|
|
|
|
struct ipcp_value *topo_next;
|
|
|
|
/* A specialized node created for this value, NULL if none has been (so far)
|
|
|
|
created. */
|
|
|
|
struct cgraph_node *spec_node;
|
|
|
|
/* Depth first search number and low link for topological sorting of
|
|
|
|
values. */
|
|
|
|
int dfs, low_link;
|
|
|
|
/* Time benefit and size cost that specializing the function for this value
|
|
|
|
would bring about in this function alone. */
|
|
|
|
int local_time_benefit, local_size_cost;
|
|
|
|
/* Time benefit and size cost that specializing the function for this value
|
|
|
|
can bring about in it's callees (transitively). */
|
|
|
|
int prop_time_benefit, prop_size_cost;
|
|
|
|
/* True if this valye is currently on the topo-sort stack. */
|
|
|
|
bool on_stack;
|
|
|
|
};
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Allocation pools for values and their sources in ipa-cp. */
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
alloc_pool ipcp_values_pool;
|
|
|
|
alloc_pool ipcp_sources_pool;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Lattice describing potential values of a formal parameter of a function and
|
|
|
|
some of their other properties. TOP is represented by a lattice with zero
|
|
|
|
values and with contains_variable and bottom flags cleared. BOTTOM is
|
|
|
|
represented by a lattice with the bottom flag set. In that case, values and
|
|
|
|
contains_variable flag should be disregarded. */
|
|
|
|
|
|
|
|
struct ipcp_lattice
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
/* The list of known values and types in this lattice. Note that values are
|
|
|
|
not deallocated if a lattice is set to bottom because there may be value
|
|
|
|
sources referencing them. */
|
|
|
|
struct ipcp_value *values;
|
|
|
|
/* Number of known values and types in this lattice. */
|
|
|
|
int values_count;
|
|
|
|
/* The lattice contains a variable component (in addition to values). */
|
|
|
|
bool contains_variable;
|
|
|
|
/* The value of the lattice is bottom (i.e. variable and unusable for any
|
|
|
|
propagation). */
|
|
|
|
bool bottom;
|
|
|
|
/* There is a virtual call based on this parameter. */
|
|
|
|
bool virt_call;
|
|
|
|
};
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Maximal count found in program. */
|
|
|
|
|
|
|
|
static gcov_type max_count;
|
|
|
|
|
|
|
|
/* Original overall size of the program. */
|
|
|
|
|
|
|
|
static long overall_size, max_new_size;
|
|
|
|
|
|
|
|
/* Head of the linked list of topologically sorted values. */
|
|
|
|
|
|
|
|
static struct ipcp_value *values_topo;
|
|
|
|
|
|
|
|
/* Return the lattice corresponding to the Ith formal parameter of the function
|
|
|
|
described by INFO. */
|
|
|
|
static inline struct ipcp_lattice *
|
|
|
|
ipa_get_lattice (struct ipa_node_params *info, int i)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-09-02 17:37:38 +02:00
|
|
|
gcc_assert (i >= 0 && i < ipa_get_param_count (info));
|
2011-07-19 00:03:39 +02:00
|
|
|
gcc_checking_assert (!info->ipcp_orig_node);
|
|
|
|
gcc_checking_assert (info->lattices);
|
|
|
|
return &(info->lattices[i]);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Return whether LAT is a lattice with a single constant and without an
|
|
|
|
undefined value. */
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
static inline bool
|
2011-07-19 00:03:39 +02:00
|
|
|
ipa_lat_is_single_const (struct ipcp_lattice *lat)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
if (lat->bottom
|
|
|
|
|| lat->contains_variable
|
|
|
|
|| lat->values_count != 1)
|
2005-08-01 09:26:30 +02:00
|
|
|
return false;
|
2011-07-19 00:03:39 +02:00
|
|
|
else
|
|
|
|
return true;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Return true iff the CS is an edge within a strongly connected component as
|
|
|
|
computed by ipa_reduced_postorder. */
|
2008-07-23 21:45:45 +02:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static inline bool
|
2011-07-19 00:03:39 +02:00
|
|
|
edge_within_scc (struct cgraph_edge *cs)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipa_dfs_info *caller_dfs = (struct ipa_dfs_info *) cs->caller->aux;
|
|
|
|
struct ipa_dfs_info *callee_dfs;
|
|
|
|
struct cgraph_node *callee = cgraph_function_node (cs->callee, NULL);
|
|
|
|
|
|
|
|
callee_dfs = (struct ipa_dfs_info *) callee->aux;
|
|
|
|
return (caller_dfs
|
|
|
|
&& callee_dfs
|
|
|
|
&& caller_dfs->scc_no == callee_dfs->scc_no);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Print V which is extracted from a value in a lattice to F. */
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
print_ipcp_constant_value (FILE * f, tree v)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
if (TREE_CODE (v) == TREE_BINFO)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (f, "BINFO ");
|
|
|
|
print_generic_expr (f, BINFO_TYPE (v), 0);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
else if (TREE_CODE (v) == ADDR_EXPR
|
|
|
|
&& TREE_CODE (TREE_OPERAND (v, 0)) == CONST_DECL)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (f, "& ");
|
|
|
|
print_generic_expr (f, DECL_INITIAL (TREE_OPERAND (v, 0)), 0);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
else
|
|
|
|
print_generic_expr (f, v, 0);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2008-05-06 16:15:18 +02:00
|
|
|
/* Print all ipcp_lattices of all functions to F. */
|
2011-07-19 00:03:39 +02:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
print_all_lattices (FILE * f, bool dump_sources, bool dump_benefits)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
struct cgraph_node *node;
|
|
|
|
int i, count;
|
2007-01-28 14:01:53 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (f, "\nLattices:\n");
|
|
|
|
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-07-17 15:23:32 +02:00
|
|
|
struct ipa_node_params *info;
|
|
|
|
|
|
|
|
info = IPA_NODE_REF (node);
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (f, " Node: %s/%i:\n", cgraph_node_name (node), node->uid);
|
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++)
|
|
|
|
{
|
gengtype.c (open_base_files): Add ipa-inline.h include.
* gengtype.c (open_base_files): Add ipa-inline.h include.
* ipa-cp.c (ipcp_get_lattice, ipcp_lattice_from_jfunc): Move to ipa-prop.c
update all uses.
* ipa-prop.c: (ipa_get_lattice, ipa_lattice_from_jfunc): ... here.
* ipa-inline-transform.c (inline_call): Use inline_merge_summary to merge
summary of inlined function into former caller.
* ipa-inline.c (max_benefit): Remove.
(edge_badness): Compensate for removal of benefits.
(update_caller_keys): Use reset_node_growth_cache/reset_edge_growth_cache.
(update_callee_keys): Likewise.
(update_all_callee_keys): Likewise.
(inline_small_functions): Do not collect max_benefit; do not
reset stimated_growth; call free_growth_caches and initialize_growth_caches.
* ipa-inline.h (struct condition, type clause_t, struct predicate, struct
size_time_entry): New structures.
(INLINE_SIZE_SCALE, INLINE_TIME_SCALE, MAX_CLAUSES): New constants.
(inline_summary): Remove size_inlining_benefit, time_inlining_benefit and
estimated_growth.
(edge_growth_cache_entry): New structure.
(node_growth_cache, edge_growth_cache): New global vars.
(estimate_growth): Turn into inline.
(inline_merge_summary, do_estimate_edge_growth, do_estimate_edge_time,
initialize_growth_caches, free_growth_caches): Declare.
(estimate_edge_growth): Rewrite.
(estimate_edge_time): Implement as inline cache lookup.
(reset_node_growth_cache, reset_edge_growth_cache): New inline functions.
(MAX_TIME): Reduce to allow multiplicatoin by INLINE_SIZE_SCALE.
(NUM_CONDITIONS): New constant.
(predicate_conditions): New enum.
(IS_NOT_CONSTANT): New constant.
(edge_removal_hook_holder): New var.
(node_growth_cache, edge_growth_cache): New global vars.
(true_predicate, single_cond_predicate, false_predicate, not_inlined_predicate,
add_condition, add_clause, and_predicates, or_predicates, predicates_equal_p,
evaulate_predicate, dump_condition, dump_clause, dump_predicate, account_size_time,
evaulate_conditions_for_edge): New functions.
(inline_summary_alloc): Move to heap.
(inline_node_removal_hook): Clear condition and entry vectors.
(inline_edge_removal_hook): New function.
(initialize_growth_caches, free_growth_caches): New function.
(dump_inline_summary): Update.
(edge_execution_predicate): New function.
(will_be_nonconstant_predicate): New function.
(estimate_function_body_sizes): Compute BB and constantness predicates.
(compute_inline_parameters): Do not clear estimated_growth.
(estimate_edge_size_and_time): New function.
(estimate_calls_size_and_time): New function.
(estimate_callee_size_and_time): New function.
(remap_predicate): New function.
(inline_merge_summary): New function.
(do_estimate_edge_time): New function based on...
(estimate_edge_time): ... this one.
(do_estimate_edge_growth): New function.
(do_estimate_growth): New function based on....
(estimate_growth): ... this one.
(inline_analyze_function): Analyze after deciding on jump functions.
(inline_read_section): New function.
(inline_read_summary): Use it.
(inline_write_summary): Write all the new data.
* ipa-prop.c (ipa_get_param_decl_index): Export.
(ipa_lattice_from_jfunc): Move here from ipa-cp.c
* ipa-prop.h (ipa_get_param_decl_index, ipa_lattice_from_jfunc): Declare.
(ipa_get_lattice): Move hre from ipa-cp.c
* Makefile.in (GTFILES): Add ipa-inline.h and ipa-inline-analysis.c
* params.def (PARAM_EARLY_INLINING_INSNS): Set to 11.
* cgraph.h (cgraph_clone_inlined_nodes, compute_inline_parameters,
cgraph_edge_inlinable_p): Remove.
* cgraphunit.c: Include ipainline.h
(cgraph_process_new_functions): Update call of compute_inline_parameters.
* gcc.dg/tree-ssa/pr38699.c: Fix testcase.
From-SVN: r172873
2011-04-22 22:04:42 +02:00
|
|
|
struct ipcp_lattice *lat = ipa_get_lattice (info, i);
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_value *val;
|
|
|
|
bool prev = false;
|
2008-07-23 21:45:45 +02:00
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
fprintf (f, " param [%d]: ", i);
|
2011-07-19 00:03:39 +02:00
|
|
|
if (lat->bottom)
|
|
|
|
{
|
|
|
|
fprintf (f, "BOTTOM\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!lat->values_count && !lat->contains_variable)
|
|
|
|
{
|
|
|
|
fprintf (f, "TOP\n");
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lat->contains_variable)
|
|
|
|
{
|
|
|
|
fprintf (f, "VARIABLE");
|
|
|
|
prev = true;
|
|
|
|
if (dump_benefits)
|
|
|
|
fprintf (f, "\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
for (val = lat->values; val; val = val->next)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
if (dump_benefits && prev)
|
|
|
|
fprintf (f, " ");
|
|
|
|
else if (!dump_benefits && prev)
|
|
|
|
fprintf (f, ", ");
|
|
|
|
else
|
|
|
|
prev = true;
|
|
|
|
|
|
|
|
print_ipcp_constant_value (f, val->value);
|
|
|
|
|
|
|
|
if (dump_sources)
|
2010-04-09 22:24:11 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_value_source *s;
|
|
|
|
|
|
|
|
fprintf (f, " [from:");
|
|
|
|
for (s = val->sources; s; s = s->next)
|
|
|
|
fprintf (f, " %i(%i)", s->cs->caller->uid,s->cs->frequency);
|
|
|
|
fprintf (f, "]");
|
2010-04-09 22:24:11 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
if (dump_benefits)
|
|
|
|
fprintf (f, " [loc_time: %i, loc_size: %i, "
|
|
|
|
"prop_time: %i, prop_size: %i]\n",
|
|
|
|
val->local_time_benefit, val->local_size_cost,
|
|
|
|
val->prop_time_benefit, val->prop_size_cost);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
if (!dump_benefits)
|
2010-08-05 15:23:07 +02:00
|
|
|
fprintf (f, "\n");
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Determine whether it is at all technically possible to create clones of NODE
|
|
|
|
and store this information in the ipa_node_params structure associated
|
|
|
|
with NODE. */
|
2009-06-26 20:23:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
static void
|
|
|
|
determine_versionability (struct cgraph_node *node)
|
2009-06-26 20:23:32 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
const char *reason = NULL;
|
2011-06-10 18:49:28 +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. */
|
2011-07-19 00:03:39 +02:00
|
|
|
if (node->alias || node->thunk.thunk_p)
|
|
|
|
reason = "alias or thunk";
|
2011-09-06 16:46:55 +02:00
|
|
|
else if (!node->local.versionable)
|
2011-09-02 17:37:38 +02:00
|
|
|
reason = "not a tree_versionable_function";
|
2011-07-19 00:03:39 +02:00
|
|
|
else if (cgraph_function_body_availability (node) <= AVAIL_OVERWRITABLE)
|
|
|
|
reason = "insufficient body availability";
|
2009-06-26 20:23:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (reason && dump_file && !node->alias && !node->thunk.thunk_p)
|
|
|
|
fprintf (dump_file, "Function %s/%i is not versionable, reason: %s.\n",
|
|
|
|
cgraph_node_name (node), node->uid, reason);
|
2009-06-26 20:23:32 +02:00
|
|
|
|
2011-09-06 16:46:55 +02:00
|
|
|
node->local.versionable = (reason == NULL);
|
2009-06-26 20:23:32 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Return true if it is at all technically possible to create clones of a
|
|
|
|
NODE. */
|
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
static bool
|
2011-07-19 00:03:39 +02:00
|
|
|
ipcp_versionable_function_p (struct cgraph_node *node)
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
2011-09-06 16:46:55 +02:00
|
|
|
return node->local.versionable;
|
2011-07-19 00:03:39 +02:00
|
|
|
}
|
2008-08-29 18:41:35 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Structure holding accumulated information about callers of a node. */
|
2011-06-10 16:57:05 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
struct caller_statistics
|
|
|
|
{
|
|
|
|
gcov_type count_sum;
|
|
|
|
int n_calls, n_hot_calls, freq_sum;
|
|
|
|
};
|
2008-08-29 18:41:35 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Initialize fields of STAT to zeroes. */
|
2010-10-26 18:40:16 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
static inline void
|
|
|
|
init_caller_stats (struct caller_statistics *stats)
|
|
|
|
{
|
|
|
|
stats->count_sum = 0;
|
|
|
|
stats->n_calls = 0;
|
|
|
|
stats->n_hot_calls = 0;
|
|
|
|
stats->freq_sum = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Worker callback of cgraph_for_node_and_aliases accumulating statistics of
|
|
|
|
non-thunk incoming edges to NODE. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
gather_caller_stats (struct cgraph_node *node, void *data)
|
|
|
|
{
|
|
|
|
struct caller_statistics *stats = (struct caller_statistics *) data;
|
|
|
|
struct cgraph_edge *cs;
|
|
|
|
|
|
|
|
for (cs = node->callers; cs; cs = cs->next_caller)
|
|
|
|
if (cs->caller->thunk.thunk_p)
|
|
|
|
cgraph_for_node_and_aliases (cs->caller, gather_caller_stats,
|
|
|
|
stats, false);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stats->count_sum += cs->count;
|
|
|
|
stats->freq_sum += cs->frequency;
|
|
|
|
stats->n_calls++;
|
|
|
|
if (cgraph_maybe_hot_edge_p (cs))
|
|
|
|
stats->n_hot_calls ++;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return true if this NODE is viable candidate for cloning. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
ipcp_cloning_candidate_p (struct cgraph_node *node)
|
|
|
|
{
|
|
|
|
struct caller_statistics stats;
|
|
|
|
|
|
|
|
gcc_checking_assert (cgraph_function_with_gimple_body_p (node));
|
2009-11-25 11:55:54 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (!flag_ipa_cp_clone)
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
|
|
|
if (dump_file)
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (dump_file, "Not considering %s for cloning; "
|
|
|
|
"-fipa-cp-clone disabled.\n",
|
2008-08-29 18:41:35 +02:00
|
|
|
cgraph_node_name (node));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (!optimize_function_for_speed_p (DECL_STRUCT_FUNCTION (node->decl)))
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
|
|
|
if (dump_file)
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (dump_file, "Not considering %s for cloning; "
|
|
|
|
"optimizing it for size.\n",
|
2008-08-29 18:41:35 +02:00
|
|
|
cgraph_node_name (node));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
init_caller_stats (&stats);
|
|
|
|
cgraph_for_node_and_aliases (node, gather_caller_stats, &stats, false);
|
|
|
|
|
|
|
|
if (inline_summary (node)->self_size < stats.n_calls)
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
|
|
|
if (dump_file)
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (dump_file, "Considering %s for cloning; code might shrink.\n",
|
2008-08-29 18:41:35 +02:00
|
|
|
cgraph_node_name (node));
|
2011-07-19 00:03:39 +02:00
|
|
|
return true;
|
2008-08-29 18:41:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* 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)
|
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
if (stats.count_sum > node->count * 90 / 100)
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
|
|
|
if (dump_file)
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (dump_file, "Considering %s for cloning; "
|
|
|
|
"usually called directly.\n",
|
2008-08-29 18:41:35 +02:00
|
|
|
cgraph_node_name (node));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
if (!stats.n_hot_calls)
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Arrays representing a topological ordering of call graph nodes and a stack
|
|
|
|
of noes used during constant propagation. */
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
struct topo_info
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct cgraph_node **order;
|
|
|
|
struct cgraph_node **stack;
|
|
|
|
int nnodes, stack_top;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Allocate the arrays in TOPO and topologically sort the nodes into order. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
build_toporder_info (struct topo_info *topo)
|
|
|
|
{
|
|
|
|
topo->order = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
|
|
|
|
topo->stack = XCNEWVEC (struct cgraph_node *, cgraph_n_nodes);
|
|
|
|
topo->stack_top = 0;
|
|
|
|
topo->nnodes = ipa_reduced_postorder (topo->order, true, true, NULL);
|
2010-08-05 15:23:07 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Free information about strongly connected components and the arrays in
|
|
|
|
TOPO. */
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
free_toporder_info (struct topo_info *topo)
|
|
|
|
{
|
|
|
|
ipa_free_postorder_info ();
|
|
|
|
free (topo->order);
|
|
|
|
free (topo->stack);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add NODE to the stack in TOPO, unless it is already there. */
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
push_node_to_stack (struct topo_info *topo, struct cgraph_node *node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
2011-07-19 00:03:39 +02:00
|
|
|
if (info->node_enqueued)
|
|
|
|
return;
|
|
|
|
info->node_enqueued = 1;
|
|
|
|
topo->stack[topo->stack_top++] = node;
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Pop a node from the stack in TOPO and return it or return NULL if the stack
|
|
|
|
is empty. */
|
2008-08-29 18:41:35 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
static struct cgraph_node *
|
|
|
|
pop_node_from_stack (struct topo_info *topo)
|
|
|
|
{
|
|
|
|
if (topo->stack_top)
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct cgraph_node *node;
|
|
|
|
topo->stack_top--;
|
|
|
|
node = topo->stack[topo->stack_top];
|
|
|
|
IPA_NODE_REF (node)->node_enqueued = 0;
|
|
|
|
return node;
|
2010-08-05 15:23:07 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
else
|
|
|
|
return NULL;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Set lattice LAT to bottom and return true if it previously was not set as
|
|
|
|
such. */
|
|
|
|
|
|
|
|
static inline bool
|
|
|
|
set_lattice_to_bottom (struct ipcp_lattice *lat)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
bool ret = !lat->bottom;
|
|
|
|
lat->bottom = true;
|
|
|
|
return ret;
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Mark lattice as containing an unknown value and return true if it previously
|
|
|
|
was not marked as such. */
|
2008-08-21 17:26:59 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
static inline bool
|
|
|
|
set_lattice_contains_variable (struct ipcp_lattice *lat)
|
|
|
|
{
|
|
|
|
bool ret = !lat->contains_variable;
|
|
|
|
lat->contains_variable = true;
|
|
|
|
return ret;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Initialize ipcp_lattices. */
|
2009-11-23 21:01:29 +01:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
initialize_node_lattices (struct cgraph_node *node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
|
|
|
struct cgraph_edge *ie;
|
|
|
|
bool disable = false, variable = false;
|
|
|
|
int i;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
gcc_checking_assert (cgraph_function_with_gimple_body_p (node));
|
2011-09-02 17:37:38 +02:00
|
|
|
if (!node->local.local)
|
2011-07-19 00:03:39 +02:00
|
|
|
{
|
|
|
|
/* When cloning is allowed, we can assume that externally visible
|
|
|
|
functions are not called. We will compensate this by cloning
|
|
|
|
later. */
|
|
|
|
if (ipcp_versionable_function_p (node)
|
|
|
|
&& ipcp_cloning_candidate_p (node))
|
|
|
|
variable = true;
|
|
|
|
else
|
|
|
|
disable = true;
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (disable || variable)
|
|
|
|
{
|
|
|
|
for (i = 0; i < ipa_get_param_count (info) ; i++)
|
|
|
|
{
|
|
|
|
struct ipcp_lattice *lat = ipa_get_lattice (info, i);
|
|
|
|
if (disable)
|
|
|
|
set_lattice_to_bottom (lat);
|
|
|
|
else
|
|
|
|
set_lattice_contains_variable (lat);
|
|
|
|
}
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS)
|
|
|
|
&& node->alias && node->thunk.thunk_p)
|
|
|
|
fprintf (dump_file, "Marking all lattices of %s/%i as %s\n",
|
|
|
|
cgraph_node_name (node), node->uid,
|
|
|
|
disable ? "BOTTOM" : "VARIABLE");
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (ie = node->indirect_calls; ie; ie = ie->next_callee)
|
|
|
|
if (ie->indirect_info->polymorphic)
|
2011-06-10 18:49:28 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
gcc_checking_assert (ie->indirect_info->param_index >= 0);
|
|
|
|
ipa_get_lattice (info, ie->indirect_info->param_index)->virt_call = 1;
|
2011-06-10 18:49:28 +02:00
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Return the result of a (possibly arithmetic) pass through jump function
|
|
|
|
JFUNC on the constant value INPUT. Return NULL_TREE if that cannot be
|
|
|
|
determined or itself is considered an interprocedural invariant. */
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
static tree
|
|
|
|
ipa_get_jf_pass_through_result (struct ipa_jump_func *jfunc, tree input)
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
tree restype, res;
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
gcc_checking_assert (is_gimple_ip_invariant (input));
|
|
|
|
if (jfunc->value.pass_through.operation == NOP_EXPR)
|
|
|
|
return input;
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (TREE_CODE_CLASS (jfunc->value.pass_through.operation)
|
|
|
|
== tcc_comparison)
|
|
|
|
restype = boolean_type_node;
|
|
|
|
else
|
|
|
|
restype = TREE_TYPE (input);
|
|
|
|
res = fold_binary (jfunc->value.pass_through.operation, restype,
|
|
|
|
input, jfunc->value.pass_through.operand);
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (res && !is_gimple_ip_invariant (res))
|
|
|
|
return NULL_TREE;
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
return res;
|
2010-08-05 15:23:07 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Return the result of an ancestor jump function JFUNC on the constant value
|
|
|
|
INPUT. Return NULL_TREE if that cannot be determined. */
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
static tree
|
|
|
|
ipa_get_jf_ancestor_result (struct ipa_jump_func *jfunc, tree input)
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
if (TREE_CODE (input) == ADDR_EXPR)
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
tree t = TREE_OPERAND (input, 0);
|
|
|
|
t = build_ref_for_offset (EXPR_LOCATION (t), t,
|
|
|
|
jfunc->value.ancestor.offset,
|
|
|
|
jfunc->value.ancestor.type, NULL, false);
|
|
|
|
return build_fold_addr_expr (t);
|
2010-08-05 15:23:07 +02:00
|
|
|
}
|
|
|
|
else
|
2011-07-19 00:03:39 +02:00
|
|
|
return NULL_TREE;
|
|
|
|
}
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Determine whether JFUNC evaluates to a known value (that is either a
|
|
|
|
constant or a binfo) and if so, return it. Otherwise return NULL. INFO
|
|
|
|
describes the caller node so that pass-through jump functions can be
|
|
|
|
evaluated. */
|
|
|
|
|
|
|
|
static tree
|
|
|
|
ipa_value_from_jfunc (struct ipa_node_params *info, struct ipa_jump_func *jfunc)
|
|
|
|
{
|
|
|
|
if (jfunc->type == IPA_JF_CONST)
|
|
|
|
return jfunc->value.constant;
|
|
|
|
else if (jfunc->type == IPA_JF_KNOWN_TYPE)
|
|
|
|
return jfunc->value.base_binfo;
|
|
|
|
else if (jfunc->type == IPA_JF_PASS_THROUGH
|
|
|
|
|| jfunc->type == IPA_JF_ANCESTOR)
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
tree input;
|
|
|
|
int idx;
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (jfunc->type == IPA_JF_PASS_THROUGH)
|
|
|
|
idx = jfunc->value.pass_through.formal_id;
|
|
|
|
else
|
|
|
|
idx = jfunc->value.ancestor.formal_id;
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (info->ipcp_orig_node)
|
|
|
|
input = VEC_index (tree, info->known_vals, idx);
|
|
|
|
else
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_lattice *lat;
|
|
|
|
|
|
|
|
if (!info->lattices)
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
gcc_checking_assert (!flag_ipa_cp);
|
|
|
|
return NULL_TREE;
|
2010-08-05 15:23:07 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
lat = ipa_get_lattice (info, idx);
|
|
|
|
if (!ipa_lat_is_single_const (lat))
|
|
|
|
return NULL_TREE;
|
|
|
|
input = lat->values->value;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!input)
|
|
|
|
return NULL_TREE;
|
|
|
|
|
|
|
|
if (jfunc->type == IPA_JF_PASS_THROUGH)
|
|
|
|
{
|
|
|
|
if (jfunc->value.pass_through.operation == NOP_EXPR)
|
|
|
|
return input;
|
|
|
|
else if (TREE_CODE (input) == TREE_BINFO)
|
|
|
|
return NULL_TREE;
|
|
|
|
else
|
|
|
|
return ipa_get_jf_pass_through_result (jfunc, input);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (TREE_CODE (input) == TREE_BINFO)
|
|
|
|
return get_binfo_at_offset (input, jfunc->value.ancestor.offset,
|
|
|
|
jfunc->value.ancestor.type);
|
|
|
|
else
|
|
|
|
return ipa_get_jf_ancestor_result (jfunc, input);
|
2010-08-05 15:23:07 +02:00
|
|
|
}
|
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
else
|
|
|
|
return NULL_TREE;
|
2010-08-05 15:23:07 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Determine whether JFUNC evaluates to a constant and if so, return it.
|
|
|
|
Otherwise return NULL. INFO describes the caller node so that pass-through
|
|
|
|
jump functions can be evaluated. */
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
tree
|
|
|
|
ipa_cst_from_jfunc (struct ipa_node_params *info, struct ipa_jump_func *jfunc)
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
tree res = ipa_value_from_jfunc (info, jfunc);
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (res && TREE_CODE (res) == TREE_BINFO)
|
|
|
|
return NULL_TREE;
|
|
|
|
else
|
|
|
|
return res;
|
|
|
|
}
|
2010-08-05 15:23:07 +02:00
|
|
|
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* If checking is enabled, verify that no lattice is in the TOP state, i.e. not
|
|
|
|
bottom, not containing a variable component and without any known value at
|
|
|
|
the same time. */
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
DEBUG_FUNCTION void
|
|
|
|
ipcp_verify_propagated_values (void)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct cgraph_node *node;
|
2008-08-29 18:41:35 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2008-05-06 16:15:18 +02:00
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
2011-07-19 00:03:39 +02:00
|
|
|
int i, count = ipa_get_param_count (info);
|
2008-05-06 16:15:18 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (i = 0; i < count; i++)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_lattice *lat = ipa_get_lattice (info, i);
|
2008-05-06 16:15:18 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (!lat->bottom
|
|
|
|
&& !lat->contains_variable
|
|
|
|
&& lat->values_count == 0)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
if (dump_file)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (dump_file, "\nIPA lattices after constant "
|
|
|
|
"propagation:\n");
|
|
|
|
print_all_lattices (dump_file, true, false);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
gcc_unreachable ();
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Return true iff X and Y should be considered equal values by IPA-CP. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
values_equal_for_ipcp_p (tree x, tree y)
|
|
|
|
{
|
|
|
|
gcc_checking_assert (x != NULL_TREE && y != NULL_TREE);
|
|
|
|
|
|
|
|
if (x == y)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (TREE_CODE (x) == TREE_BINFO || TREE_CODE (y) == TREE_BINFO)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (TREE_CODE (x) == ADDR_EXPR
|
|
|
|
&& TREE_CODE (y) == ADDR_EXPR
|
|
|
|
&& TREE_CODE (TREE_OPERAND (x, 0)) == CONST_DECL
|
|
|
|
&& TREE_CODE (TREE_OPERAND (y, 0)) == CONST_DECL)
|
|
|
|
return operand_equal_p (DECL_INITIAL (TREE_OPERAND (x, 0)),
|
|
|
|
DECL_INITIAL (TREE_OPERAND (y, 0)), 0);
|
|
|
|
else
|
|
|
|
return operand_equal_p (x, y, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Add a new value source to VAL, marking that a value comes from edge CS and
|
|
|
|
(if the underlying jump function is a pass-through or an ancestor one) from
|
|
|
|
a caller value SRC_VAL of a caller parameter described by SRC_INDEX. */
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
add_value_source (struct ipcp_value *val, struct cgraph_edge *cs,
|
|
|
|
struct ipcp_value *src_val, int src_idx)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_value_source *src;
|
2008-08-29 18:41:35 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
src = (struct ipcp_value_source *) pool_alloc (ipcp_sources_pool);
|
|
|
|
src->cs = cs;
|
|
|
|
src->val = src_val;
|
|
|
|
src->index = src_idx;
|
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
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
src->next = val->sources;
|
|
|
|
val->sources = src;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Try to add NEWVAL to LAT, potentially creating a new struct ipcp_value for
|
|
|
|
it. CS, SRC_VAL and SRC_INDEX are meant for add_value_source and have the
|
|
|
|
same meaning. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
add_value_to_lattice (struct ipcp_lattice *lat, tree newval,
|
|
|
|
struct cgraph_edge *cs, struct ipcp_value *src_val,
|
|
|
|
int src_idx)
|
|
|
|
{
|
|
|
|
struct ipcp_value *val;
|
|
|
|
|
|
|
|
if (lat->bottom)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
for (val = lat->values; val; val = val->next)
|
|
|
|
if (values_equal_for_ipcp_p (val->value, newval))
|
|
|
|
{
|
|
|
|
if (edge_within_scc (cs))
|
|
|
|
{
|
|
|
|
struct ipcp_value_source *s;
|
|
|
|
for (s = val->sources; s ; s = s->next)
|
|
|
|
if (s->cs == cs)
|
|
|
|
break;
|
|
|
|
if (s)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
add_value_source (val, cs, src_val, src_idx);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lat->values_count == PARAM_VALUE (PARAM_IPA_CP_VALUE_LIST_SIZE))
|
|
|
|
{
|
|
|
|
/* We can only free sources, not the values themselves, because sources
|
|
|
|
of other values in this this SCC might point to them. */
|
|
|
|
for (val = lat->values; val; val = val->next)
|
|
|
|
{
|
|
|
|
while (val->sources)
|
|
|
|
{
|
|
|
|
struct ipcp_value_source *src = val->sources;
|
|
|
|
val->sources = src->next;
|
|
|
|
pool_free (ipcp_sources_pool, src);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
lat->values = NULL;
|
|
|
|
return set_lattice_to_bottom (lat);
|
|
|
|
}
|
|
|
|
|
|
|
|
lat->values_count++;
|
|
|
|
val = (struct ipcp_value *) pool_alloc (ipcp_values_pool);
|
|
|
|
memset (val, 0, sizeof (*val));
|
|
|
|
|
|
|
|
add_value_source (val, cs, src_val, src_idx);
|
|
|
|
val->value = newval;
|
|
|
|
val->next = lat->values;
|
|
|
|
lat->values = val;
|
|
|
|
return true;
|
|
|
|
}
|
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
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Propagate values through a pass-through jump function JFUNC associated with
|
|
|
|
edge CS, taking values from SRC_LAT and putting them into DEST_LAT. SRC_IDX
|
|
|
|
is the index of the source parameter. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
propagate_vals_accross_pass_through (struct cgraph_edge *cs,
|
|
|
|
struct ipa_jump_func *jfunc,
|
|
|
|
struct ipcp_lattice *src_lat,
|
|
|
|
struct ipcp_lattice *dest_lat,
|
|
|
|
int src_idx)
|
|
|
|
{
|
|
|
|
struct ipcp_value *src_val;
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
if (jfunc->value.pass_through.operation == NOP_EXPR)
|
|
|
|
for (src_val = src_lat->values; src_val; src_val = src_val->next)
|
|
|
|
ret |= add_value_to_lattice (dest_lat, src_val->value, cs,
|
|
|
|
src_val, src_idx);
|
|
|
|
/* Do not create new values when propagating within an SCC because if there
|
|
|
|
arithmetic functions with circular dependencies, there is infinite number
|
|
|
|
of them and we would just make lattices bottom. */
|
|
|
|
else if (edge_within_scc (cs))
|
|
|
|
ret = set_lattice_contains_variable (dest_lat);
|
|
|
|
else
|
|
|
|
for (src_val = src_lat->values; src_val; src_val = src_val->next)
|
2011-06-10 18:49:28 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
tree cstval = src_val->value;
|
|
|
|
|
|
|
|
if (TREE_CODE (cstval) == TREE_BINFO)
|
|
|
|
{
|
|
|
|
ret |= set_lattice_contains_variable (dest_lat);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
cstval = ipa_get_jf_pass_through_result (jfunc, cstval);
|
|
|
|
|
|
|
|
if (cstval)
|
|
|
|
ret |= add_value_to_lattice (dest_lat, cstval, cs, src_val, src_idx);
|
|
|
|
else
|
|
|
|
ret |= set_lattice_contains_variable (dest_lat);
|
2011-06-10 18:49:28 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Propagate values through an ancestor jump function JFUNC associated with
|
|
|
|
edge CS, taking values from SRC_LAT and putting them into DEST_LAT. SRC_IDX
|
|
|
|
is the index of the source parameter. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
propagate_vals_accross_ancestor (struct cgraph_edge *cs,
|
|
|
|
struct ipa_jump_func *jfunc,
|
|
|
|
struct ipcp_lattice *src_lat,
|
|
|
|
struct ipcp_lattice *dest_lat,
|
|
|
|
int src_idx)
|
|
|
|
{
|
|
|
|
struct ipcp_value *src_val;
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
if (edge_within_scc (cs))
|
|
|
|
return set_lattice_contains_variable (dest_lat);
|
|
|
|
|
|
|
|
for (src_val = src_lat->values; src_val; src_val = src_val->next)
|
|
|
|
{
|
|
|
|
tree t = src_val->value;
|
|
|
|
|
|
|
|
if (TREE_CODE (t) == TREE_BINFO)
|
|
|
|
t = get_binfo_at_offset (t, jfunc->value.ancestor.offset,
|
|
|
|
jfunc->value.ancestor.type);
|
|
|
|
else
|
|
|
|
t = ipa_get_jf_ancestor_result (jfunc, t);
|
|
|
|
|
|
|
|
if (t)
|
|
|
|
ret |= add_value_to_lattice (dest_lat, t, cs, src_val, src_idx);
|
|
|
|
else
|
|
|
|
ret |= set_lattice_contains_variable (dest_lat);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Propagate values across jump function JFUNC that is associated with edge CS
|
|
|
|
and put the values into DEST_LAT. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
propagate_accross_jump_function (struct cgraph_edge *cs,
|
|
|
|
struct ipa_jump_func *jfunc,
|
|
|
|
struct ipcp_lattice *dest_lat)
|
|
|
|
{
|
|
|
|
if (dest_lat->bottom)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (jfunc->type == IPA_JF_CONST
|
|
|
|
|| jfunc->type == IPA_JF_KNOWN_TYPE)
|
|
|
|
{
|
|
|
|
tree val;
|
|
|
|
|
|
|
|
if (jfunc->type == IPA_JF_KNOWN_TYPE)
|
|
|
|
val = jfunc->value.base_binfo;
|
|
|
|
else
|
|
|
|
val = jfunc->value.constant;
|
|
|
|
return add_value_to_lattice (dest_lat, val, cs, NULL, 0);
|
|
|
|
}
|
|
|
|
else if (jfunc->type == IPA_JF_PASS_THROUGH
|
|
|
|
|| jfunc->type == IPA_JF_ANCESTOR)
|
|
|
|
{
|
|
|
|
struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
|
|
|
|
struct ipcp_lattice *src_lat;
|
|
|
|
int src_idx;
|
|
|
|
bool ret;
|
|
|
|
|
|
|
|
if (jfunc->type == IPA_JF_PASS_THROUGH)
|
|
|
|
src_idx = jfunc->value.pass_through.formal_id;
|
|
|
|
else
|
|
|
|
src_idx = jfunc->value.ancestor.formal_id;
|
|
|
|
|
|
|
|
src_lat = ipa_get_lattice (caller_info, src_idx);
|
|
|
|
if (src_lat->bottom)
|
|
|
|
return set_lattice_contains_variable (dest_lat);
|
|
|
|
|
|
|
|
/* If we would need to clone the caller and cannot, do not propagate. */
|
|
|
|
if (!ipcp_versionable_function_p (cs->caller)
|
|
|
|
&& (src_lat->contains_variable
|
|
|
|
|| (src_lat->values_count > 1)))
|
|
|
|
return set_lattice_contains_variable (dest_lat);
|
|
|
|
|
|
|
|
if (jfunc->type == IPA_JF_PASS_THROUGH)
|
|
|
|
ret = propagate_vals_accross_pass_through (cs, jfunc, src_lat,
|
|
|
|
dest_lat, src_idx);
|
|
|
|
else
|
|
|
|
ret = propagate_vals_accross_ancestor (cs, jfunc, src_lat, dest_lat,
|
|
|
|
src_idx);
|
|
|
|
|
|
|
|
if (src_lat->contains_variable)
|
|
|
|
ret |= set_lattice_contains_variable (dest_lat);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* TODO: We currently do not handle member method pointers in IPA-CP (we only
|
|
|
|
use it for indirect inlining), we should propagate them too. */
|
|
|
|
return set_lattice_contains_variable (dest_lat);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Propagate constants from the caller to the callee of CS. INFO describes the
|
|
|
|
caller. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
propagate_constants_accross_call (struct cgraph_edge *cs)
|
|
|
|
{
|
|
|
|
struct ipa_node_params *callee_info;
|
|
|
|
enum availability availability;
|
|
|
|
struct cgraph_node *callee, *alias_or_thunk;
|
|
|
|
struct ipa_edge_args *args;
|
|
|
|
bool ret = false;
|
2011-09-02 17:37:38 +02:00
|
|
|
int i, args_count, parms_count;
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
callee = cgraph_function_node (cs->callee, &availability);
|
|
|
|
if (!callee->analyzed)
|
|
|
|
return false;
|
|
|
|
gcc_checking_assert (cgraph_function_with_gimple_body_p (callee));
|
|
|
|
callee_info = IPA_NODE_REF (callee);
|
|
|
|
|
|
|
|
args = IPA_EDGE_REF (cs);
|
2011-09-02 17:37:38 +02:00
|
|
|
args_count = ipa_get_cs_argument_count (args);
|
|
|
|
parms_count = ipa_get_param_count (callee_info);
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
/* If this call goes through a thunk we must not propagate to the first (0th)
|
|
|
|
parameter. However, we might need to uncover a thunk from below a series
|
|
|
|
of aliases first. */
|
|
|
|
alias_or_thunk = cs->callee;
|
|
|
|
while (alias_or_thunk->alias)
|
|
|
|
alias_or_thunk = cgraph_alias_aliased_node (alias_or_thunk);
|
|
|
|
if (alias_or_thunk->thunk.thunk_p)
|
|
|
|
{
|
|
|
|
ret |= set_lattice_contains_variable (ipa_get_lattice (callee_info, 0));
|
|
|
|
i = 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
i = 0;
|
|
|
|
|
2011-09-02 17:37:38 +02:00
|
|
|
for (; (i < args_count) && (i < parms_count); i++)
|
2011-07-19 00:03:39 +02:00
|
|
|
{
|
|
|
|
struct ipa_jump_func *jump_func = ipa_get_ith_jump_func (args, i);
|
|
|
|
struct ipcp_lattice *dest_lat = ipa_get_lattice (callee_info, i);
|
|
|
|
|
|
|
|
if (availability == AVAIL_OVERWRITABLE)
|
|
|
|
ret |= set_lattice_contains_variable (dest_lat);
|
|
|
|
else
|
|
|
|
ret |= propagate_accross_jump_function (cs, jump_func, dest_lat);
|
|
|
|
}
|
2011-09-02 17:37:38 +02:00
|
|
|
for (; i < parms_count; i++)
|
|
|
|
ret |= set_lattice_contains_variable (ipa_get_lattice (callee_info, i));
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* If an indirect edge IE can be turned into a direct one based on KNOWN_VALS
|
|
|
|
(which can contain both constants and binfos) or KNOWN_BINFOS (which can be
|
2011-09-02 15:26:30 +02:00
|
|
|
NULL) return the destination. */
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
static tree
|
2011-09-02 15:26:30 +02:00
|
|
|
get_indirect_edge_target (struct cgraph_edge *ie,
|
2011-07-19 00:03:39 +02:00
|
|
|
VEC (tree, heap) *known_vals,
|
|
|
|
VEC (tree, heap) *known_binfos)
|
|
|
|
{
|
|
|
|
int param_index = ie->indirect_info->param_index;
|
|
|
|
HOST_WIDE_INT token, anc_offset;
|
|
|
|
tree otr_type;
|
|
|
|
tree t;
|
|
|
|
|
|
|
|
if (param_index == -1)
|
|
|
|
return NULL_TREE;
|
|
|
|
|
|
|
|
if (!ie->indirect_info->polymorphic)
|
|
|
|
{
|
|
|
|
tree t = VEC_index (tree, known_vals, param_index);
|
|
|
|
if (t &&
|
|
|
|
TREE_CODE (t) == ADDR_EXPR
|
|
|
|
&& TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL)
|
2011-09-02 15:26:30 +02:00
|
|
|
return TREE_OPERAND (t, 0);
|
2011-07-19 00:03:39 +02:00
|
|
|
else
|
|
|
|
return NULL_TREE;
|
|
|
|
}
|
|
|
|
|
|
|
|
token = ie->indirect_info->otr_token;
|
|
|
|
anc_offset = ie->indirect_info->anc_offset;
|
|
|
|
otr_type = ie->indirect_info->otr_type;
|
|
|
|
|
|
|
|
t = VEC_index (tree, known_vals, param_index);
|
|
|
|
if (!t && known_binfos)
|
|
|
|
t = VEC_index (tree, known_binfos, param_index);
|
|
|
|
if (!t)
|
|
|
|
return NULL_TREE;
|
|
|
|
|
|
|
|
if (TREE_CODE (t) != TREE_BINFO)
|
|
|
|
{
|
|
|
|
tree binfo;
|
|
|
|
binfo = gimple_extract_devirt_binfo_from_cst (t);
|
|
|
|
if (!binfo)
|
|
|
|
return NULL_TREE;
|
|
|
|
binfo = get_binfo_at_offset (binfo, anc_offset, otr_type);
|
|
|
|
if (!binfo)
|
|
|
|
return NULL_TREE;
|
2011-09-02 15:26:30 +02:00
|
|
|
return gimple_get_virt_method_for_binfo (token, binfo);
|
2011-07-19 00:03:39 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
tree binfo;
|
|
|
|
|
|
|
|
binfo = get_binfo_at_offset (t, anc_offset, otr_type);
|
|
|
|
if (!binfo)
|
|
|
|
return NULL_TREE;
|
2011-09-02 15:26:30 +02:00
|
|
|
return gimple_get_virt_method_for_binfo (token, binfo);
|
2011-07-19 00:03:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate devirtualization time bonus for NODE, assuming we know KNOWN_CSTS
|
|
|
|
and KNOWN_BINFOS. */
|
|
|
|
|
|
|
|
static int
|
|
|
|
devirtualization_time_bonus (struct cgraph_node *node,
|
|
|
|
VEC (tree, heap) *known_csts,
|
|
|
|
VEC (tree, heap) *known_binfos)
|
|
|
|
{
|
|
|
|
struct cgraph_edge *ie;
|
|
|
|
int res = 0;
|
|
|
|
|
|
|
|
for (ie = node->indirect_calls; ie; ie = ie->next_callee)
|
|
|
|
{
|
|
|
|
struct cgraph_node *callee;
|
|
|
|
struct inline_summary *isummary;
|
2011-09-02 15:26:30 +02:00
|
|
|
tree target;
|
2011-07-19 00:03:39 +02:00
|
|
|
|
2011-09-02 15:26:30 +02:00
|
|
|
target = get_indirect_edge_target (ie, known_csts, known_binfos);
|
2011-07-19 00:03:39 +02:00
|
|
|
if (!target)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* Only bare minimum benefit for clearly un-inlineable targets. */
|
|
|
|
res += 1;
|
|
|
|
callee = cgraph_get_node (target);
|
|
|
|
if (!callee || !callee->analyzed)
|
|
|
|
continue;
|
|
|
|
isummary = inline_summary (callee);
|
|
|
|
if (!isummary->inlinable)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* FIXME: The values below need re-considering and perhaps also
|
|
|
|
integrating into the cost metrics, at lest in some very basic way. */
|
|
|
|
if (isummary->size <= MAX_INLINE_INSNS_AUTO / 4)
|
|
|
|
res += 31;
|
|
|
|
else if (isummary->size <= MAX_INLINE_INSNS_AUTO / 2)
|
|
|
|
res += 15;
|
|
|
|
else if (isummary->size <= MAX_INLINE_INSNS_AUTO
|
|
|
|
|| DECL_DECLARED_INLINE_P (callee->decl))
|
|
|
|
res += 7;
|
|
|
|
}
|
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return true if cloning NODE is a good idea, given the estimated TIME_BENEFIT
|
|
|
|
and SIZE_COST and with the sum of frequencies of incoming edges to the
|
|
|
|
potential new clone in FREQUENCIES. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
good_cloning_opportunity_p (struct cgraph_node *node, int time_benefit,
|
|
|
|
int freq_sum, gcov_type count_sum, int size_cost)
|
|
|
|
{
|
|
|
|
if (time_benefit == 0
|
|
|
|
|| !flag_ipa_cp_clone
|
|
|
|
|| !optimize_function_for_speed_p (DECL_STRUCT_FUNCTION (node->decl)))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
gcc_checking_assert (size_cost >= 0);
|
|
|
|
|
|
|
|
/* FIXME: These decisions need tuning. */
|
|
|
|
if (max_count)
|
|
|
|
{
|
|
|
|
int evaluation, factor = (count_sum * 1000) / max_count;
|
|
|
|
|
|
|
|
evaluation = (time_benefit * factor) / size_cost;
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file, " good_cloning_opportunity_p (time: %i, "
|
|
|
|
"size: %i, count_sum: " HOST_WIDE_INT_PRINT_DEC
|
|
|
|
") -> evaluation: %i, threshold: %i\n",
|
|
|
|
time_benefit, size_cost, (HOST_WIDE_INT) count_sum,
|
|
|
|
evaluation, 500);
|
|
|
|
|
|
|
|
return evaluation >= PARAM_VALUE (PARAM_IPA_CP_EVAL_THRESHOLD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int evaluation = (time_benefit * freq_sum) / size_cost;
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file, " good_cloning_opportunity_p (time: %i, "
|
|
|
|
"size: %i, freq_sum: %i) -> evaluation: %i, threshold: %i\n",
|
|
|
|
time_benefit, size_cost, freq_sum, evaluation,
|
|
|
|
CGRAPH_FREQ_BASE /2);
|
|
|
|
|
|
|
|
return evaluation >= PARAM_VALUE (PARAM_IPA_CP_EVAL_THRESHOLD);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Allocate KNOWN_CSTS and KNOWN_BINFOS and populate them with values of
|
|
|
|
parameters that are known independent of the context. INFO describes the
|
|
|
|
function. If REMOVABLE_PARAMS_COST is non-NULL, the movement cost of all
|
|
|
|
removable parameters will be stored in it. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
gather_context_independent_values (struct ipa_node_params *info,
|
|
|
|
VEC (tree, heap) **known_csts,
|
|
|
|
VEC (tree, heap) **known_binfos,
|
|
|
|
int *removable_params_cost)
|
|
|
|
{
|
|
|
|
int i, count = ipa_get_param_count (info);
|
|
|
|
bool ret = false;
|
|
|
|
|
|
|
|
*known_csts = NULL;
|
|
|
|
*known_binfos = NULL;
|
|
|
|
VEC_safe_grow_cleared (tree, heap, *known_csts, count);
|
|
|
|
VEC_safe_grow_cleared (tree, heap, *known_binfos, count);
|
|
|
|
|
|
|
|
if (removable_params_cost)
|
|
|
|
*removable_params_cost = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < count ; i++)
|
|
|
|
{
|
|
|
|
struct ipcp_lattice *lat = ipa_get_lattice (info, i);
|
|
|
|
|
|
|
|
if (ipa_lat_is_single_const (lat))
|
|
|
|
{
|
|
|
|
struct ipcp_value *val = lat->values;
|
|
|
|
if (TREE_CODE (val->value) != TREE_BINFO)
|
|
|
|
{
|
|
|
|
VEC_replace (tree, *known_csts, i, val->value);
|
|
|
|
if (removable_params_cost)
|
|
|
|
*removable_params_cost
|
|
|
|
+= estimate_move_cost (TREE_TYPE (val->value));
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
else if (lat->virt_call)
|
|
|
|
{
|
|
|
|
VEC_replace (tree, *known_binfos, i, val->value);
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
else if (removable_params_cost
|
|
|
|
&& !ipa_is_param_used (info, i))
|
|
|
|
*removable_params_cost
|
|
|
|
+= estimate_move_cost (TREE_TYPE (ipa_get_param (info, i)));
|
|
|
|
}
|
|
|
|
else if (removable_params_cost
|
|
|
|
&& !ipa_is_param_used (info, i))
|
|
|
|
*removable_params_cost
|
|
|
|
+= estimate_move_cost (TREE_TYPE (ipa_get_param (info, i)));
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Iterate over known values of parameters of NODE and estimate the local
|
|
|
|
effects in terms of time and size they have. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
estimate_local_effects (struct cgraph_node *node)
|
|
|
|
{
|
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
|
|
|
int i, count = ipa_get_param_count (info);
|
|
|
|
VEC (tree, heap) *known_csts, *known_binfos;
|
|
|
|
bool always_const;
|
|
|
|
int base_time = inline_summary (node)->time;
|
|
|
|
int removable_params_cost;
|
|
|
|
|
|
|
|
if (!count || !ipcp_versionable_function_p (node))
|
|
|
|
return;
|
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (dump_file, "\nEstimating effects for %s/%i, base_time: %i.\n",
|
|
|
|
cgraph_node_name (node), node->uid, base_time);
|
|
|
|
|
|
|
|
always_const = gather_context_independent_values (info, &known_csts,
|
|
|
|
&known_binfos,
|
|
|
|
&removable_params_cost);
|
|
|
|
if (always_const)
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct caller_statistics stats;
|
|
|
|
int time, size;
|
|
|
|
|
|
|
|
init_caller_stats (&stats);
|
|
|
|
cgraph_for_node_and_aliases (node, gather_caller_stats, &stats, false);
|
|
|
|
estimate_ipcp_clone_size_and_time (node, known_csts, &size, &time);
|
|
|
|
time -= devirtualization_time_bonus (node, known_csts, known_binfos);
|
|
|
|
time -= removable_params_cost;
|
|
|
|
size -= stats.n_calls * removable_params_cost;
|
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, " - context independent values, size: %i, "
|
|
|
|
"time_benefit: %i\n", size, base_time - time);
|
|
|
|
|
|
|
|
if (size <= 0
|
|
|
|
|| cgraph_will_be_removed_from_program_if_no_direct_calls (node))
|
|
|
|
{
|
|
|
|
info->clone_for_all_contexts = true;
|
|
|
|
base_time = time;
|
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, " Decided to specialize for all "
|
|
|
|
"known contexts, code not going to grow.\n");
|
|
|
|
}
|
|
|
|
else if (good_cloning_opportunity_p (node, base_time - time,
|
|
|
|
stats.freq_sum, stats.count_sum,
|
|
|
|
size))
|
|
|
|
{
|
|
|
|
if (size + overall_size <= max_new_size)
|
|
|
|
{
|
|
|
|
info->clone_for_all_contexts = true;
|
|
|
|
base_time = time;
|
|
|
|
overall_size += size;
|
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, " Decided to specialize for all "
|
|
|
|
"known contexts, growth deemed beneficial.\n");
|
|
|
|
}
|
|
|
|
else if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file, " Not cloning for all contexts because "
|
|
|
|
"max_new_size would be reached with %li.\n",
|
|
|
|
size + overall_size);
|
|
|
|
}
|
2008-08-29 18:41:35 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (i = 0; i < count ; i++)
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_lattice *lat = ipa_get_lattice (info, i);
|
|
|
|
struct ipcp_value *val;
|
|
|
|
int emc;
|
|
|
|
|
|
|
|
if (lat->bottom
|
|
|
|
|| !lat->values
|
|
|
|
|| VEC_index (tree, known_csts, i)
|
|
|
|
|| VEC_index (tree, known_binfos, i))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
for (val = lat->values; val; val = val->next)
|
|
|
|
{
|
|
|
|
int time, size, time_benefit;
|
|
|
|
|
|
|
|
if (TREE_CODE (val->value) != TREE_BINFO)
|
|
|
|
{
|
|
|
|
VEC_replace (tree, known_csts, i, val->value);
|
|
|
|
VEC_replace (tree, known_binfos, i, NULL_TREE);
|
|
|
|
emc = estimate_move_cost (TREE_TYPE (val->value));
|
|
|
|
}
|
|
|
|
else if (lat->virt_call)
|
|
|
|
{
|
|
|
|
VEC_replace (tree, known_csts, i, NULL_TREE);
|
|
|
|
VEC_replace (tree, known_binfos, i, val->value);
|
|
|
|
emc = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
continue;
|
|
|
|
|
|
|
|
estimate_ipcp_clone_size_and_time (node, known_csts, &size, &time);
|
|
|
|
time_benefit = base_time - time
|
|
|
|
+ devirtualization_time_bonus (node, known_csts, known_binfos)
|
|
|
|
+ removable_params_cost + emc;
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
{
|
|
|
|
fprintf (dump_file, " - estimates for value ");
|
|
|
|
print_ipcp_constant_value (dump_file, val->value);
|
|
|
|
fprintf (dump_file, " for parameter ");
|
|
|
|
print_generic_expr (dump_file, ipa_get_param (info, i), 0);
|
|
|
|
fprintf (dump_file, ": time_benefit: %i, size: %i\n",
|
|
|
|
time_benefit, size);
|
|
|
|
}
|
|
|
|
|
|
|
|
val->local_time_benefit = time_benefit;
|
|
|
|
val->local_size_cost = size;
|
|
|
|
}
|
2008-08-29 18:41:35 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
VEC_free (tree, heap, known_csts);
|
|
|
|
VEC_free (tree, heap, known_binfos);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Add value CUR_VAL and all yet-unsorted values it is dependent on to the
|
|
|
|
topological sort of values. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_val_to_toposort (struct ipcp_value *cur_val)
|
|
|
|
{
|
|
|
|
static int dfs_counter = 0;
|
|
|
|
static struct ipcp_value *stack;
|
|
|
|
struct ipcp_value_source *src;
|
|
|
|
|
|
|
|
if (cur_val->dfs)
|
|
|
|
return;
|
|
|
|
|
|
|
|
dfs_counter++;
|
|
|
|
cur_val->dfs = dfs_counter;
|
|
|
|
cur_val->low_link = dfs_counter;
|
|
|
|
|
|
|
|
cur_val->topo_next = stack;
|
|
|
|
stack = cur_val;
|
|
|
|
cur_val->on_stack = true;
|
|
|
|
|
|
|
|
for (src = cur_val->sources; src; src = src->next)
|
|
|
|
if (src->val)
|
|
|
|
{
|
|
|
|
if (src->val->dfs == 0)
|
|
|
|
{
|
|
|
|
add_val_to_toposort (src->val);
|
|
|
|
if (src->val->low_link < cur_val->low_link)
|
|
|
|
cur_val->low_link = src->val->low_link;
|
|
|
|
}
|
|
|
|
else if (src->val->on_stack
|
|
|
|
&& src->val->dfs < cur_val->low_link)
|
|
|
|
cur_val->low_link = src->val->dfs;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (cur_val->dfs == cur_val->low_link)
|
2008-08-29 18:41:35 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_value *v, *scc_list = NULL;
|
|
|
|
|
|
|
|
do
|
|
|
|
{
|
|
|
|
v = stack;
|
|
|
|
stack = v->topo_next;
|
|
|
|
v->on_stack = false;
|
|
|
|
|
|
|
|
v->scc_next = scc_list;
|
|
|
|
scc_list = v;
|
|
|
|
}
|
|
|
|
while (v != cur_val);
|
|
|
|
|
|
|
|
cur_val->topo_next = values_topo;
|
|
|
|
values_topo = cur_val;
|
2008-08-29 18:41:35 +02:00
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Add all values in lattices associated with NODE to the topological sort if
|
|
|
|
they are not there yet. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
add_all_node_vals_to_toposort (struct cgraph_node *node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
|
|
|
int i, count = ipa_get_param_count (info);
|
|
|
|
|
|
|
|
for (i = 0; i < count ; i++)
|
|
|
|
{
|
|
|
|
struct ipcp_lattice *lat = ipa_get_lattice (info, i);
|
|
|
|
struct ipcp_value *val;
|
|
|
|
|
|
|
|
if (lat->bottom || !lat->values)
|
|
|
|
continue;
|
|
|
|
for (val = lat->values; val; val = val->next)
|
|
|
|
add_val_to_toposort (val);
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* One pass of constants propagation along the call graph edges, from callers
|
|
|
|
to callees (requires topological ordering in TOPO), iterate over strongly
|
|
|
|
connected components. */
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
propagate_constants_topo (struct topo_info *topo)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
int i;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (i = topo->nnodes - 1; i >= 0; i--)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct cgraph_node *v, *node = topo->order[i];
|
|
|
|
struct ipa_dfs_info *node_dfs_info;
|
|
|
|
|
|
|
|
if (!cgraph_function_with_gimple_body_p (node))
|
2008-07-17 15:23:32 +02:00
|
|
|
continue;
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
node_dfs_info = (struct ipa_dfs_info *) node->aux;
|
|
|
|
/* First, iteratively propagate within the strongly connected component
|
|
|
|
until all lattices stabilize. */
|
|
|
|
v = node_dfs_info->next_cycle;
|
|
|
|
while (v)
|
|
|
|
{
|
|
|
|
push_node_to_stack (topo, v);
|
|
|
|
v = ((struct ipa_dfs_info *) v->aux)->next_cycle;
|
|
|
|
}
|
|
|
|
|
|
|
|
v = node;
|
|
|
|
while (v)
|
|
|
|
{
|
|
|
|
struct cgraph_edge *cs;
|
|
|
|
|
|
|
|
for (cs = v->callees; cs; cs = cs->next_callee)
|
|
|
|
if (edge_within_scc (cs)
|
|
|
|
&& propagate_constants_accross_call (cs))
|
|
|
|
push_node_to_stack (topo, cs->callee);
|
|
|
|
v = pop_node_from_stack (topo);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Afterwards, propagate along edges leading out of the SCC, calculates
|
|
|
|
the local effects of the discovered constants and all valid values to
|
|
|
|
their topological sort. */
|
|
|
|
v = node;
|
|
|
|
while (v)
|
|
|
|
{
|
|
|
|
struct cgraph_edge *cs;
|
|
|
|
|
|
|
|
estimate_local_effects (v);
|
|
|
|
add_all_node_vals_to_toposort (v);
|
|
|
|
for (cs = v->callees; cs; cs = cs->next_callee)
|
|
|
|
if (!edge_within_scc (cs))
|
|
|
|
propagate_constants_accross_call (cs);
|
|
|
|
|
|
|
|
v = ((struct ipa_dfs_info *) v->aux)->next_cycle;
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Propagate the estimated effects of individual values along the topological
|
|
|
|
from the dependant values to those they depend on. */
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
propagate_effects (void)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_value *base;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (base = values_topo; base; base = base->topo_next)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_value_source *src;
|
|
|
|
struct ipcp_value *val;
|
|
|
|
int time = 0, size = 0;
|
|
|
|
|
|
|
|
for (val = base; val; val = val->scc_next)
|
|
|
|
{
|
|
|
|
time += val->local_time_benefit + val->prop_time_benefit;
|
|
|
|
size += val->local_size_cost + val->prop_size_cost;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (val = base; val; val = val->scc_next)
|
|
|
|
for (src = val->sources; src; src = src->next)
|
|
|
|
if (src->val
|
|
|
|
&& cgraph_maybe_hot_edge_p (src->cs))
|
|
|
|
{
|
|
|
|
src->val->prop_time_benefit += time;
|
|
|
|
src->val->prop_size_cost += size;
|
|
|
|
}
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
/* Propagate constants, binfos and their effects from the summaries
|
|
|
|
interprocedurally. */
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
ipcp_propagate_stage (struct topo_info *topo)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
struct cgraph_node *node;
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "\n Propagating constants:\n\n");
|
|
|
|
|
|
|
|
if (in_lto_p)
|
|
|
|
ipa_update_after_lto_read ();
|
|
|
|
|
|
|
|
|
|
|
|
FOR_EACH_DEFINED_FUNCTION (node)
|
|
|
|
{
|
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
|
|
|
|
|
|
|
determine_versionability (node);
|
|
|
|
if (cgraph_function_with_gimple_body_p (node))
|
|
|
|
{
|
|
|
|
info->lattices = XCNEWVEC (struct ipcp_lattice,
|
|
|
|
ipa_get_param_count (info));
|
|
|
|
initialize_node_lattices (node);
|
|
|
|
}
|
|
|
|
if (node->count > max_count)
|
|
|
|
max_count = node->count;
|
|
|
|
overall_size += inline_summary (node)->self_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "\noverall_size: %li, max_new_size: %li\n",
|
|
|
|
overall_size, max_new_size);
|
|
|
|
|
|
|
|
propagate_constants_topo (topo);
|
|
|
|
#ifdef ENABLE_CHECKING
|
|
|
|
ipcp_verify_propagated_values ();
|
|
|
|
#endif
|
|
|
|
propagate_effects ();
|
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
{
|
|
|
|
fprintf (dump_file, "\nIPA lattices after all propagation:\n");
|
|
|
|
print_all_lattices (dump_file, (dump_flags & TDF_DETAILS), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Discover newly direct outgoing edges from NODE which is a new clone with
|
|
|
|
known KNOWN_VALS and make them direct. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipcp_discover_new_direct_edges (struct cgraph_node *node,
|
|
|
|
VEC (tree, heap) *known_vals)
|
|
|
|
{
|
|
|
|
struct cgraph_edge *ie, *next_ie;
|
|
|
|
|
|
|
|
for (ie = node->indirect_calls; ie; ie = next_ie)
|
|
|
|
{
|
2011-09-02 15:26:30 +02:00
|
|
|
tree target;
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
next_ie = ie->next_callee;
|
2011-09-02 15:26:30 +02:00
|
|
|
target = get_indirect_edge_target (ie, known_vals, NULL);
|
2011-07-19 00:03:39 +02:00
|
|
|
if (target)
|
2011-09-02 15:26:30 +02:00
|
|
|
ipa_make_edge_direct_to_target (ie, target);
|
2011-07-19 00:03:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Vector of pointers which for linked lists of clones of an original crgaph
|
|
|
|
edge. */
|
|
|
|
|
|
|
|
static VEC (cgraph_edge_p, heap) *next_edge_clone;
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
grow_next_edge_clone_vector (void)
|
|
|
|
{
|
|
|
|
if (VEC_length (cgraph_edge_p, next_edge_clone)
|
|
|
|
<= (unsigned) cgraph_edge_max_uid)
|
|
|
|
VEC_safe_grow_cleared (cgraph_edge_p, heap, next_edge_clone,
|
|
|
|
cgraph_edge_max_uid + 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Edge duplication hook to grow the appropriate linked list in
|
|
|
|
next_edge_clone. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipcp_edge_duplication_hook (struct cgraph_edge *src, struct cgraph_edge *dst,
|
|
|
|
__attribute__((unused)) void *data)
|
|
|
|
{
|
|
|
|
grow_next_edge_clone_vector ();
|
|
|
|
VEC_replace (cgraph_edge_p, next_edge_clone, dst->uid,
|
|
|
|
VEC_index (cgraph_edge_p, next_edge_clone, src->uid));
|
|
|
|
VEC_replace (cgraph_edge_p, next_edge_clone, src->uid, dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the next clone in the linked list of clones of an edge. */
|
|
|
|
|
|
|
|
static inline struct cgraph_edge *
|
|
|
|
get_next_cgraph_edge_clone (struct cgraph_edge *cs)
|
|
|
|
{
|
|
|
|
return VEC_index (cgraph_edge_p, next_edge_clone, cs->uid);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return true if edge CS does bring about the value described by SRC. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
cgraph_edge_brings_value_p (struct cgraph_edge *cs,
|
|
|
|
struct ipcp_value_source *src)
|
|
|
|
{
|
|
|
|
struct ipa_node_params *caller_info = IPA_NODE_REF (cs->caller);
|
|
|
|
|
|
|
|
if (IPA_NODE_REF (cs->callee)->ipcp_orig_node
|
|
|
|
|| caller_info->node_dead)
|
|
|
|
return false;
|
|
|
|
if (!src->val)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
if (caller_info->ipcp_orig_node)
|
|
|
|
{
|
|
|
|
tree t = VEC_index (tree, caller_info->known_vals, src->index);
|
|
|
|
return (t != NULL_TREE
|
|
|
|
&& values_equal_for_ipcp_p (src->val->value, t));
|
|
|
|
}
|
|
|
|
else
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_lattice *lat = ipa_get_lattice (caller_info, src->index);
|
|
|
|
if (ipa_lat_is_single_const (lat)
|
|
|
|
&& values_equal_for_ipcp_p (src->val->value, lat->values->value))
|
|
|
|
return true;
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Given VAL, iterate over all its sources and if they still hold, add their
|
|
|
|
edge frequency and their number into *FREQUENCY and *CALLER_COUNT
|
|
|
|
respectively. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
get_info_about_necessary_edges (struct ipcp_value *val, int *freq_sum,
|
|
|
|
gcov_type *count_sum, int *caller_count)
|
|
|
|
{
|
|
|
|
struct ipcp_value_source *src;
|
|
|
|
int freq = 0, count = 0;
|
|
|
|
gcov_type cnt = 0;
|
|
|
|
bool hot = false;
|
|
|
|
|
|
|
|
for (src = val->sources; src; src = src->next)
|
|
|
|
{
|
|
|
|
struct cgraph_edge *cs = src->cs;
|
|
|
|
while (cs)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
if (cgraph_edge_brings_value_p (cs, src))
|
|
|
|
{
|
|
|
|
count++;
|
|
|
|
freq += cs->frequency;
|
|
|
|
cnt += cs->count;
|
|
|
|
hot |= cgraph_maybe_hot_edge_p (cs);
|
|
|
|
}
|
|
|
|
cs = get_next_cgraph_edge_clone (cs);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
*freq_sum = freq;
|
|
|
|
*count_sum = cnt;
|
|
|
|
*caller_count = count;
|
|
|
|
return hot;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Return a vector of incoming edges that do bring value VAL. It is assumed
|
|
|
|
their number is known and equal to CALLER_COUNT. */
|
|
|
|
|
|
|
|
static VEC (cgraph_edge_p,heap) *
|
|
|
|
gather_edges_for_value (struct ipcp_value *val, int caller_count)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipcp_value_source *src;
|
|
|
|
VEC (cgraph_edge_p,heap) *ret;
|
|
|
|
|
|
|
|
ret = VEC_alloc (cgraph_edge_p, heap, caller_count);
|
|
|
|
for (src = val->sources; src; src = src->next)
|
|
|
|
{
|
|
|
|
struct cgraph_edge *cs = src->cs;
|
|
|
|
while (cs)
|
|
|
|
{
|
|
|
|
if (cgraph_edge_brings_value_p (cs, src))
|
|
|
|
VEC_quick_push (cgraph_edge_p, ret, cs);
|
|
|
|
cs = get_next_cgraph_edge_clone (cs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Construct a replacement map for a know VALUE for a formal parameter PARAM.
|
|
|
|
Return it or NULL if for some reason it cannot be created. */
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static struct ipa_replace_map *
|
2011-07-19 00:03:39 +02:00
|
|
|
get_replacement_map (tree value, tree parm)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
tree req_type = TREE_TYPE (parm);
|
2005-08-01 09:26:30 +02:00
|
|
|
struct ipa_replace_map *replace_map;
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (!useless_type_conversion_p (req_type, TREE_TYPE (value)))
|
2011-03-05 00:07:20 +01:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
if (fold_convertible_p (req_type, value))
|
|
|
|
value = fold_build1 (NOP_EXPR, req_type, value);
|
|
|
|
else if (TYPE_SIZE (req_type) == TYPE_SIZE (TREE_TYPE (value)))
|
|
|
|
value = fold_build1 (VIEW_CONVERT_EXPR, req_type, value);
|
|
|
|
else
|
2011-03-05 00:07:20 +01:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
if (dump_file)
|
|
|
|
{
|
|
|
|
fprintf (dump_file, " const ");
|
|
|
|
print_generic_expr (dump_file, value, 0);
|
|
|
|
fprintf (dump_file, " can't be converted to param ");
|
|
|
|
print_generic_expr (dump_file, parm, 0);
|
|
|
|
fprintf (dump_file, "\n");
|
|
|
|
}
|
|
|
|
return NULL;
|
2011-03-05 00:07:20 +01:00
|
|
|
}
|
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
|
2011-03-05 00:07:20 +01:00
|
|
|
replace_map = ggc_alloc_ipa_replace_map ();
|
2008-08-29 13:31:40 +02:00
|
|
|
if (dump_file)
|
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (dump_file, " replacing param ");
|
|
|
|
print_generic_expr (dump_file, parm, 0);
|
2008-08-29 13:31:40 +02:00
|
|
|
fprintf (dump_file, " with const ");
|
2011-07-19 00:03:39 +02:00
|
|
|
print_generic_expr (dump_file, value, 0);
|
2008-08-29 13:31:40 +02:00
|
|
|
fprintf (dump_file, "\n");
|
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
replace_map->old_tree = parm;
|
|
|
|
replace_map->new_tree = value;
|
2008-08-24 00:25:20 +02:00
|
|
|
replace_map->replace_p = true;
|
|
|
|
replace_map->ref_p = false;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
|
|
|
return replace_map;
|
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Dump new profiling counts */
|
2005-08-01 09:26:30 +02:00
|
|
|
|
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
dump_profile_updates (struct cgraph_node *orig_node,
|
|
|
|
struct cgraph_node *new_node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct cgraph_edge *cs;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (dump_file, " setting count of the specialized node to "
|
|
|
|
HOST_WIDE_INT_PRINT_DEC "\n", (HOST_WIDE_INT) new_node->count);
|
|
|
|
for (cs = new_node->callees; cs ; cs = cs->next_callee)
|
|
|
|
fprintf (dump_file, " edge to %s has count "
|
|
|
|
HOST_WIDE_INT_PRINT_DEC "\n",
|
|
|
|
cgraph_node_name (cs->callee), (HOST_WIDE_INT) cs->count);
|
|
|
|
|
|
|
|
fprintf (dump_file, " setting count of the original node to "
|
|
|
|
HOST_WIDE_INT_PRINT_DEC "\n", (HOST_WIDE_INT) orig_node->count);
|
|
|
|
for (cs = orig_node->callees; cs ; cs = cs->next_callee)
|
|
|
|
fprintf (dump_file, " edge to %s is left with "
|
|
|
|
HOST_WIDE_INT_PRINT_DEC "\n",
|
|
|
|
cgraph_node_name (cs->callee), (HOST_WIDE_INT) cs->count);
|
|
|
|
}
|
2008-08-29 13:31:40 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* After a specialized NEW_NODE version of ORIG_NODE has been created, update
|
|
|
|
their profile information to reflect this. */
|
2005-08-01 09:26:30 +02:00
|
|
|
|
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
update_profiling_info (struct cgraph_node *orig_node,
|
|
|
|
struct cgraph_node *new_node)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
|
|
|
struct cgraph_edge *cs;
|
2011-07-19 00:03:39 +02:00
|
|
|
struct caller_statistics stats;
|
|
|
|
gcov_type new_sum, orig_sum;
|
|
|
|
gcov_type remainder, orig_node_count = orig_node->count;
|
|
|
|
|
|
|
|
if (orig_node_count == 0)
|
|
|
|
return;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
init_caller_stats (&stats);
|
|
|
|
cgraph_for_node_and_aliases (orig_node, gather_caller_stats, &stats, false);
|
|
|
|
orig_sum = stats.count_sum;
|
|
|
|
init_caller_stats (&stats);
|
|
|
|
cgraph_for_node_and_aliases (new_node, gather_caller_stats, &stats, false);
|
|
|
|
new_sum = stats.count_sum;
|
|
|
|
|
|
|
|
if (orig_node_count < orig_sum + new_sum)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, " Problem: node %s/%i has too low count "
|
|
|
|
HOST_WIDE_INT_PRINT_DEC " while the sum of incoming "
|
|
|
|
"counts is " HOST_WIDE_INT_PRINT_DEC "\n",
|
|
|
|
cgraph_node_name (orig_node), orig_node->uid,
|
|
|
|
(HOST_WIDE_INT) orig_node_count,
|
|
|
|
(HOST_WIDE_INT) (orig_sum + new_sum));
|
|
|
|
|
|
|
|
orig_node_count = (orig_sum + new_sum) * 12 / 10;
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, " proceeding by pretending it was "
|
|
|
|
HOST_WIDE_INT_PRINT_DEC "\n",
|
|
|
|
(HOST_WIDE_INT) orig_node_count);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
new_node->count = new_sum;
|
|
|
|
remainder = orig_node_count - new_sum;
|
|
|
|
orig_node->count = remainder;
|
|
|
|
|
|
|
|
for (cs = new_node->callees; cs ; cs = cs->next_callee)
|
|
|
|
if (cs->frequency)
|
2011-07-26 14:26:58 +02:00
|
|
|
cs->count = cs->count * (new_sum * REG_BR_PROB_BASE
|
|
|
|
/ orig_node_count) / REG_BR_PROB_BASE;
|
2011-07-19 00:03:39 +02:00
|
|
|
else
|
|
|
|
cs->count = 0;
|
|
|
|
|
|
|
|
for (cs = orig_node->callees; cs ; cs = cs->next_callee)
|
2011-07-26 14:26:58 +02:00
|
|
|
cs->count = cs->count * (remainder * REG_BR_PROB_BASE
|
|
|
|
/ orig_node_count) / REG_BR_PROB_BASE;
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
dump_profile_updates (orig_node, new_node);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Update the respective profile of specialized NEW_NODE and the original
|
|
|
|
ORIG_NODE after additional edges with cumulative count sum REDIRECTED_SUM
|
|
|
|
have been redirected to the specialized version. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
update_specialized_profile (struct cgraph_node *new_node,
|
|
|
|
struct cgraph_node *orig_node,
|
|
|
|
gcov_type redirected_sum)
|
2008-08-24 22:09:32 +02:00
|
|
|
{
|
2008-08-31 18:45:05 +02:00
|
|
|
struct cgraph_edge *cs;
|
2011-07-19 00:03:39 +02:00
|
|
|
gcov_type new_node_count, orig_node_count = orig_node->count;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, " the sum of counts of redirected edges is "
|
|
|
|
HOST_WIDE_INT_PRINT_DEC "\n", (HOST_WIDE_INT) redirected_sum);
|
|
|
|
if (orig_node_count == 0)
|
|
|
|
return;
|
2008-08-31 18:45:05 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
gcc_assert (orig_node_count >= redirected_sum);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
new_node_count = new_node->count;
|
|
|
|
new_node->count += redirected_sum;
|
|
|
|
orig_node->count -= redirected_sum;
|
2008-08-31 18:45:05 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (cs = new_node->callees; cs ; cs = cs->next_callee)
|
|
|
|
if (cs->frequency)
|
|
|
|
cs->count += cs->count * redirected_sum / new_node_count;
|
|
|
|
else
|
|
|
|
cs->count = 0;
|
2008-08-31 18:45:05 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (cs = orig_node->callees; cs ; cs = cs->next_callee)
|
|
|
|
{
|
2011-07-26 14:26:58 +02:00
|
|
|
gcov_type dec = cs->count * (redirected_sum * REG_BR_PROB_BASE
|
|
|
|
/ orig_node_count) / REG_BR_PROB_BASE;
|
2011-07-19 00:03:39 +02:00
|
|
|
if (dec < cs->count)
|
|
|
|
cs->count -= dec;
|
|
|
|
else
|
|
|
|
cs->count = 0;
|
|
|
|
}
|
2008-08-31 18:45:05 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (dump_file)
|
|
|
|
dump_profile_updates (orig_node, new_node);
|
2008-08-24 22:09:32 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Create a specialized version of NODE with known constants and types of
|
|
|
|
parameters in KNOWN_VALS and redirect all edges in CALLERS to it. */
|
2008-08-31 18:45:05 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
static struct cgraph_node *
|
|
|
|
create_specialized_node (struct cgraph_node *node,
|
|
|
|
VEC (tree, heap) *known_vals,
|
|
|
|
VEC (cgraph_edge_p,heap) *callers)
|
2008-08-24 22:09:32 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipa_node_params *new_info, *info = IPA_NODE_REF (node);
|
|
|
|
VEC (ipa_replace_map_p,gc)* replace_trees = NULL;
|
|
|
|
struct cgraph_node *new_node;
|
|
|
|
int i, count = ipa_get_param_count (info);
|
|
|
|
bitmap args_to_skip;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
gcc_assert (!info->ipcp_orig_node);
|
|
|
|
|
|
|
|
if (node->local.can_change_signature)
|
2008-08-24 22:09:32 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
args_to_skip = BITMAP_GGC_ALLOC ();
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
tree t = VEC_index (tree, known_vals, i);
|
|
|
|
|
|
|
|
if ((t && TREE_CODE (t) != TREE_BINFO)
|
|
|
|
|| !ipa_is_param_used (info, i))
|
|
|
|
bitmap_set_bit (args_to_skip, i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2011-09-02 17:37:38 +02:00
|
|
|
{
|
|
|
|
args_to_skip = NULL;
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file, " cannot change function signature\n");
|
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
for (i = 0; i < count ; i++)
|
|
|
|
{
|
|
|
|
tree t = VEC_index (tree, known_vals, i);
|
|
|
|
if (t && TREE_CODE (t) != TREE_BINFO)
|
|
|
|
{
|
|
|
|
struct ipa_replace_map *replace_map;
|
|
|
|
|
|
|
|
replace_map = get_replacement_map (t, ipa_get_param (info, i));
|
|
|
|
if (replace_map)
|
|
|
|
VEC_safe_push (ipa_replace_map_p, gc, replace_trees, replace_map);
|
|
|
|
}
|
2008-08-24 22:09:32 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
new_node = cgraph_create_virtual_clone (node, callers, replace_trees,
|
|
|
|
args_to_skip, "constprop");
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file, " the new node is %s/%i.\n",
|
|
|
|
cgraph_node_name (new_node), new_node->uid);
|
|
|
|
gcc_checking_assert (ipa_node_params_vector
|
|
|
|
&& (VEC_length (ipa_node_params_t,
|
|
|
|
ipa_node_params_vector)
|
|
|
|
> (unsigned) cgraph_max_uid));
|
|
|
|
update_profiling_info (node, new_node);
|
|
|
|
new_info = IPA_NODE_REF (new_node);
|
|
|
|
new_info->ipcp_orig_node = node;
|
|
|
|
new_info->known_vals = known_vals;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
ipcp_discover_new_direct_edges (new_node, known_vals);
|
|
|
|
|
|
|
|
VEC_free (cgraph_edge_p, heap, callers);
|
|
|
|
return new_node;
|
2008-08-24 22:09:32 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Given a NODE, and a subset of its CALLERS, try to populate blanks slots in
|
|
|
|
KNOWN_VALS with constants and types that are also known for all of the
|
|
|
|
CALLERS. */
|
2010-08-05 15:23:07 +02:00
|
|
|
|
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
find_more_values_for_callers_subset (struct cgraph_node *node,
|
|
|
|
VEC (tree, heap) *known_vals,
|
|
|
|
VEC (cgraph_edge_p,heap) *callers)
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
2011-07-19 00:03:39 +02:00
|
|
|
int i, count = ipa_get_param_count (info);
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (i = 0; i < count ; i++)
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct cgraph_edge *cs;
|
|
|
|
tree newval = NULL_TREE;
|
|
|
|
int j;
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (ipa_get_lattice (info, i)->bottom
|
|
|
|
|| VEC_index (tree, known_vals, i))
|
2010-08-05 15:23:07 +02:00
|
|
|
continue;
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
FOR_EACH_VEC_ELT (cgraph_edge_p, callers, j, cs)
|
2011-04-19 18:35:33 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipa_jump_func *jump_func;
|
|
|
|
tree t;
|
2011-04-19 18:15:08 +02:00
|
|
|
|
2011-09-07 16:31:40 +02:00
|
|
|
if (i >= ipa_get_cs_argument_count (IPA_EDGE_REF (cs)))
|
|
|
|
{
|
|
|
|
newval = NULL_TREE;
|
|
|
|
break;
|
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
jump_func = ipa_get_ith_jump_func (IPA_EDGE_REF (cs), i);
|
|
|
|
t = ipa_value_from_jfunc (IPA_NODE_REF (cs->caller), jump_func);
|
|
|
|
if (!t
|
|
|
|
|| (newval
|
|
|
|
&& !values_equal_for_ipcp_p (t, newval)))
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
newval = NULL_TREE;
|
|
|
|
break;
|
2010-08-05 15:23:07 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
else
|
|
|
|
newval = t;
|
2010-08-05 15:23:07 +02:00
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (newval)
|
|
|
|
{
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
{
|
|
|
|
fprintf (dump_file, " adding an extra known value ");
|
|
|
|
print_ipcp_constant_value (dump_file, newval);
|
|
|
|
fprintf (dump_file, " for parameter ");
|
|
|
|
print_generic_expr (dump_file, ipa_get_param (info, i), 0);
|
|
|
|
fprintf (dump_file, "\n");
|
|
|
|
}
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
VEC_replace (tree, known_vals, i, newval);
|
|
|
|
}
|
2008-08-24 22:09:32 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Given an original NODE and a VAL for which we have already created a
|
|
|
|
specialized clone, look whether there are incoming edges that still lead
|
|
|
|
into the old node but now also bring the requested value and also conform to
|
|
|
|
all other criteria such that they can be redirected the the special node.
|
|
|
|
This function can therefore redirect the final edge in a SCC. */
|
2010-08-05 15:30:14 +02:00
|
|
|
|
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
perhaps_add_new_callers (struct cgraph_node *node, struct ipcp_value *val)
|
2010-08-05 15:30:14 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct ipa_node_params *dest_info = IPA_NODE_REF (val->spec_node);
|
|
|
|
struct ipcp_value_source *src;
|
|
|
|
int count = ipa_get_param_count (dest_info);
|
|
|
|
gcov_type redirected_sum = 0;
|
2010-08-05 15:30:14 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (src = val->sources; src; src = src->next)
|
2010-08-05 15:30:14 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct cgraph_edge *cs = src->cs;
|
|
|
|
while (cs)
|
|
|
|
{
|
|
|
|
enum availability availability;
|
|
|
|
bool insufficient = false;
|
2010-08-05 15:30:14 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (cgraph_function_node (cs->callee, &availability) == node
|
|
|
|
&& availability > AVAIL_OVERWRITABLE
|
|
|
|
&& cgraph_edge_brings_value_p (cs, src))
|
|
|
|
{
|
|
|
|
struct ipa_node_params *caller_info;
|
|
|
|
struct ipa_edge_args *args;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
caller_info = IPA_NODE_REF (cs->caller);
|
|
|
|
args = IPA_EDGE_REF (cs);
|
|
|
|
for (i = 0; i < count; i++)
|
|
|
|
{
|
|
|
|
struct ipa_jump_func *jump_func;
|
|
|
|
tree val, t;
|
|
|
|
|
|
|
|
val = VEC_index (tree, dest_info->known_vals, i);
|
|
|
|
if (!val)
|
|
|
|
continue;
|
2010-08-05 15:30:14 +02:00
|
|
|
|
2011-09-07 16:31:40 +02:00
|
|
|
if (i >= ipa_get_cs_argument_count (args))
|
|
|
|
{
|
|
|
|
insufficient = true;
|
|
|
|
break;
|
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
jump_func = ipa_get_ith_jump_func (args, i);
|
|
|
|
t = ipa_value_from_jfunc (caller_info, jump_func);
|
|
|
|
if (!t || !values_equal_for_ipcp_p (val, t))
|
|
|
|
{
|
|
|
|
insufficient = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!insufficient)
|
|
|
|
{
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, " - adding an extra caller %s/%i"
|
|
|
|
" of %s/%i\n",
|
|
|
|
cgraph_node_name (cs->caller), cs->caller->uid,
|
|
|
|
cgraph_node_name (val->spec_node),
|
|
|
|
val->spec_node->uid);
|
|
|
|
|
|
|
|
cgraph_redirect_edge_callee (cs, val->spec_node);
|
|
|
|
redirected_sum += cs->count;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cs = get_next_cgraph_edge_clone (cs);
|
|
|
|
}
|
2010-08-05 15:30:14 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
if (redirected_sum)
|
|
|
|
update_specialized_profile (val->spec_node, node, redirected_sum);
|
2010-08-05 15:30:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Copy KNOWN_BINFOS to KNOWN_VALS. */
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
static void
|
2011-07-19 00:03:39 +02:00
|
|
|
move_binfos_to_values (VEC (tree, heap) *known_vals,
|
|
|
|
VEC (tree, heap) *known_binfos)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
tree t;
|
2008-08-24 22:09:32 +02:00
|
|
|
int i;
|
2005-08-01 09:26:30 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (i = 0; VEC_iterate (tree, known_binfos, i, t); i++)
|
|
|
|
if (t)
|
|
|
|
VEC_replace (tree, known_vals, i, t);
|
|
|
|
}
|
2008-08-24 22:09:32 +02:00
|
|
|
|
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Decide whether and what specialized clones of NODE should be created. */
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
static bool
|
|
|
|
decide_whether_version_node (struct cgraph_node *node)
|
|
|
|
{
|
|
|
|
struct ipa_node_params *info = IPA_NODE_REF (node);
|
|
|
|
int i, count = ipa_get_param_count (info);
|
|
|
|
VEC (tree, heap) *known_csts, *known_binfos;
|
|
|
|
bool ret = false;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (count == 0)
|
|
|
|
return false;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file, "\nEvaluating opportunities for %s/%i.\n",
|
|
|
|
cgraph_node_name (node), node->uid);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
gather_context_independent_values (info, &known_csts, &known_binfos,
|
|
|
|
NULL);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (i = 0; i < count ; i++)
|
|
|
|
{
|
|
|
|
struct ipcp_lattice *lat = ipa_get_lattice (info, i);
|
|
|
|
struct ipcp_value *val;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (lat->bottom
|
|
|
|
|| VEC_index (tree, known_csts, i)
|
|
|
|
|| VEC_index (tree, known_binfos, i))
|
|
|
|
continue;
|
2011-01-26 15:06:20 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (val = lat->values; val; val = val->next)
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
int freq_sum, caller_count;
|
|
|
|
gcov_type count_sum;
|
|
|
|
VEC (cgraph_edge_p, heap) *callers;
|
|
|
|
VEC (tree, heap) *kv;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (val->spec_node)
|
2008-08-29 13:31:40 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
perhaps_add_new_callers (node, val);
|
2008-08-29 13:31:40 +02:00
|
|
|
continue;
|
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
else if (val->local_size_cost + overall_size > max_new_size)
|
|
|
|
{
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
fprintf (dump_file, " Ignoring candidate value because "
|
|
|
|
"max_new_size would be reached with %li.\n",
|
|
|
|
val->local_size_cost + overall_size);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
else if (!get_info_about_necessary_edges (val, &freq_sum, &count_sum,
|
|
|
|
&caller_count))
|
|
|
|
continue;
|
2008-08-29 13:31:40 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
2005-08-01 09:26:30 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (dump_file, " - considering value ");
|
|
|
|
print_ipcp_constant_value (dump_file, val->value);
|
|
|
|
fprintf (dump_file, " for parameter ");
|
|
|
|
print_generic_expr (dump_file, ipa_get_param (info, i), 0);
|
|
|
|
fprintf (dump_file, " (caller_count: %i)\n", caller_count);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
|
|
|
|
if (!good_cloning_opportunity_p (node, val->local_time_benefit,
|
|
|
|
freq_sum, count_sum,
|
|
|
|
val->local_size_cost)
|
|
|
|
&& !good_cloning_opportunity_p (node,
|
|
|
|
val->local_time_benefit
|
|
|
|
+ val->prop_time_benefit,
|
|
|
|
freq_sum, count_sum,
|
|
|
|
val->local_size_cost
|
|
|
|
+ val->prop_size_cost))
|
|
|
|
continue;
|
|
|
|
|
2011-03-05 00:07:20 +01:00
|
|
|
if (dump_file)
|
2011-07-19 00:03:39 +02:00
|
|
|
fprintf (dump_file, " Creating a specialized node of %s/%i.\n",
|
|
|
|
cgraph_node_name (node), node->uid);
|
|
|
|
|
|
|
|
callers = gather_edges_for_value (val, caller_count);
|
|
|
|
kv = VEC_copy (tree, heap, known_csts);
|
|
|
|
move_binfos_to_values (kv, known_binfos);
|
|
|
|
VEC_replace (tree, kv, i, val->value);
|
|
|
|
find_more_values_for_callers_subset (node, kv, callers);
|
|
|
|
val->spec_node = create_specialized_node (node, kv, callers);
|
|
|
|
overall_size += val->local_size_cost;
|
|
|
|
info = IPA_NODE_REF (node);
|
|
|
|
|
|
|
|
/* TODO: If for some lattice there is only one other known value
|
|
|
|
left, make a special node for it too. */
|
|
|
|
ret = true;
|
|
|
|
|
|
|
|
VEC_replace (tree, kv, i, val->value);
|
2011-03-05 00:07:20 +01:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
}
|
2011-03-05 00:07:20 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (info->clone_for_all_contexts)
|
|
|
|
{
|
|
|
|
VEC (cgraph_edge_p, heap) *callers;
|
2011-03-05 00:07:20 +01:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, " - Creating a specialized node of %s/%i "
|
|
|
|
"for all known contexts.\n", cgraph_node_name (node),
|
|
|
|
node->uid);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
callers = collect_callers_of_node (node);
|
|
|
|
move_binfos_to_values (known_csts, known_binfos);
|
|
|
|
create_specialized_node (node, known_csts, callers);
|
|
|
|
info = IPA_NODE_REF (node);
|
|
|
|
info->clone_for_all_contexts = false;
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
VEC_free (tree, heap, known_csts);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
VEC_free (tree, heap, known_binfos);
|
|
|
|
return ret;
|
|
|
|
}
|
2009-05-08 21:19:51 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
/* Transitively mark all callees of NODE within the same SCC as not dead. */
|
2010-08-05 15:23:07 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
static void
|
|
|
|
spread_undeadness (struct cgraph_node *node)
|
|
|
|
{
|
|
|
|
struct cgraph_edge *cs;
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (cs = node->callees; cs; cs = cs->next_callee)
|
|
|
|
if (edge_within_scc (cs))
|
|
|
|
{
|
|
|
|
struct cgraph_node *callee;
|
|
|
|
struct ipa_node_params *info;
|
2008-08-21 17:26:59 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
callee = cgraph_function_node (cs->callee, NULL);
|
|
|
|
info = IPA_NODE_REF (callee);
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
if (info->node_dead)
|
|
|
|
{
|
|
|
|
info->node_dead = 0;
|
|
|
|
spread_undeadness (callee);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Return true if NODE has a caller from outside of its SCC that is not
|
|
|
|
dead. Worker callback for cgraph_for_node_and_aliases. */
|
|
|
|
|
|
|
|
static bool
|
|
|
|
has_undead_caller_from_outside_scc_p (struct cgraph_node *node,
|
|
|
|
void *data ATTRIBUTE_UNUSED)
|
|
|
|
{
|
|
|
|
struct cgraph_edge *cs;
|
|
|
|
|
|
|
|
for (cs = node->callers; cs; cs = cs->next_caller)
|
|
|
|
if (cs->caller->thunk.thunk_p
|
|
|
|
&& cgraph_for_node_and_aliases (cs->caller,
|
|
|
|
has_undead_caller_from_outside_scc_p,
|
|
|
|
NULL, true))
|
|
|
|
return true;
|
|
|
|
else if (!edge_within_scc (cs)
|
|
|
|
&& !IPA_NODE_REF (cs->caller)->node_dead)
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Identify nodes within the same SCC as NODE which are no longer needed
|
|
|
|
because of new clones and will be removed as unreachable. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
identify_dead_nodes (struct cgraph_node *node)
|
|
|
|
{
|
|
|
|
struct cgraph_node *v;
|
|
|
|
for (v = node; v ; v = ((struct ipa_dfs_info *) v->aux)->next_cycle)
|
|
|
|
if (cgraph_will_be_removed_from_program_if_no_direct_calls (v)
|
|
|
|
&& !cgraph_for_node_and_aliases (v,
|
|
|
|
has_undead_caller_from_outside_scc_p,
|
|
|
|
NULL, true))
|
|
|
|
IPA_NODE_REF (v)->node_dead = 1;
|
|
|
|
|
|
|
|
for (v = node; v ; v = ((struct ipa_dfs_info *) v->aux)->next_cycle)
|
|
|
|
if (!IPA_NODE_REF (v)->node_dead)
|
|
|
|
spread_undeadness (v);
|
|
|
|
|
|
|
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
|
|
|
{
|
|
|
|
for (v = node; v ; v = ((struct ipa_dfs_info *) v->aux)->next_cycle)
|
|
|
|
if (IPA_NODE_REF (v)->node_dead)
|
|
|
|
fprintf (dump_file, " Marking node as dead: %s/%i.\n",
|
|
|
|
cgraph_node_name (v), v->uid);
|
2008-08-24 22:09:32 +02:00
|
|
|
}
|
2011-07-19 00:03:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The decision stage. Iterate over the topological order of call graph nodes
|
|
|
|
TOPO and make specialized clones if deemed beneficial. */
|
|
|
|
|
|
|
|
static void
|
|
|
|
ipcp_decision_stage (struct topo_info *topo)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (dump_file)
|
|
|
|
fprintf (dump_file, "\nIPA decision stage:\n\n");
|
2008-08-24 22:09:32 +02:00
|
|
|
|
2011-07-19 00:03:39 +02:00
|
|
|
for (i = topo->nnodes - 1; i >= 0; i--)
|
2008-08-24 22:09:32 +02:00
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct cgraph_node *node = topo->order[i];
|
|
|
|
bool change = false, iterate = true;
|
|
|
|
|
|
|
|
while (iterate)
|
|
|
|
{
|
|
|
|
struct cgraph_node *v;
|
|
|
|
iterate = false;
|
|
|
|
for (v = node; v ; v = ((struct ipa_dfs_info *) v->aux)->next_cycle)
|
|
|
|
if (cgraph_function_with_gimple_body_p (v)
|
|
|
|
&& ipcp_versionable_function_p (v))
|
|
|
|
iterate |= decide_whether_version_node (v);
|
|
|
|
|
|
|
|
change |= iterate;
|
|
|
|
}
|
|
|
|
if (change)
|
|
|
|
identify_dead_nodes (node);
|
2005-08-01 09:26:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* The IPCP driver. */
|
2011-07-19 00:03:39 +02:00
|
|
|
|
2007-01-28 14:01:53 +01:00
|
|
|
static unsigned int
|
2005-08-01 09:26:30 +02:00
|
|
|
ipcp_driver (void)
|
|
|
|
{
|
2011-07-19 00:03:39 +02:00
|
|
|
struct cgraph_2edge_hook_list *edge_duplication_hook_holder;
|
|
|
|
struct topo_info topo;
|
|
|
|
|
2008-08-29 18:41:35 +02:00
|
|
|
cgraph_remove_unreachable_nodes (true,dump_file);
|
2011-07-19 00:03:39 +02:00
|
|
|
ipa_check_create_node_params ();
|
|
|
|
ipa_check_create_edge_args ();
|
|
|
|
grow_next_edge_clone_vector ();
|
|
|
|
edge_duplication_hook_holder =
|
|
|
|
cgraph_add_edge_duplication_hook (&ipcp_edge_duplication_hook, NULL);
|
|
|
|
ipcp_values_pool = create_alloc_pool ("IPA-CP values",
|
|
|
|
sizeof (struct ipcp_value), 32);
|
|
|
|
ipcp_sources_pool = create_alloc_pool ("IPA-CP value sources",
|
|
|
|
sizeof (struct ipcp_value_source), 64);
|
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-07-19 00:03:39 +02:00
|
|
|
|
|
|
|
/* Topological sort. */
|
|
|
|
build_toporder_info (&topo);
|
|
|
|
/* Do the interprocedural propagation. */
|
|
|
|
ipcp_propagate_stage (&topo);
|
|
|
|
/* Decide what constant propagation and cloning should be performed. */
|
|
|
|
ipcp_decision_stage (&topo);
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
/* Free all IPCP structures. */
|
2011-07-19 00:03:39 +02:00
|
|
|
free_toporder_info (&topo);
|
|
|
|
VEC_free (cgraph_edge_p, heap, next_edge_clone);
|
|
|
|
cgraph_remove_edge_duplication_hook (edge_duplication_hook_holder);
|
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
|
|
|
|
2011-05-07 01:00:49 +02:00
|
|
|
FOR_EACH_FUNCTION_WITH_GIMPLE_BODY (node)
|
2010-08-05 15:23:07 +02:00
|
|
|
{
|
|
|
|
/* Unreachable nodes should have been eliminated before ipcp. */
|
|
|
|
gcc_assert (node->needed || node->reachable);
|
2011-09-06 16:46:55 +02:00
|
|
|
node->local.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. */
|
2011-07-19 00:03:39 +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
|
|
|
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. */
|
2011-07-19 00:03:39 +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
|
|
|
static void
|
|
|
|
ipcp_read_summary (void)
|
|
|
|
{
|
|
|
|
ipa_prop_read_jump_functions ();
|
|
|
|
}
|
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
/* Gate for IPCP optimization. */
|
2011-07-19 00:03:39 +02:00
|
|
|
|
2005-08-01 09:26:30 +02:00
|
|
|
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 */
|
2011-06-14 21:39:36 +02:00
|
|
|
TODO_dump_cgraph |
|
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
|
|
|
};
|