aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-inline.c
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2018-06-19 16:31:20 +0200
committerMartin Liska <marxin@gcc.gnu.org>2018-06-19 14:31:20 +0000
commit56f62793be7b655f02889ef04f58df0d6e8fb1af (patch)
treeda7e8d5740c33deef542777f2e070540666b5575 /gcc/ipa-inline.c
parented0eb0c55ae33aae3ff6c076dc59d5cab8b4b02c (diff)
downloadgcc-56f62793be7b655f02889ef04f58df0d6e8fb1af.zip
gcc-56f62793be7b655f02889ef04f58df0d6e8fb1af.tar.gz
gcc-56f62793be7b655f02889ef04f58df0d6e8fb1af.tar.bz2
Clean-up usage of ipa_fn_summary and ipa_call_summary summaries.
2018-06-19 Martin Liska <mliska@suse.cz> * config/i386/i386.c (ix86_can_inline_p): Do not use ipa_fn_summaries::get_create. * ipa-cp.c (ipcp_cloning_candidate_p): Replace get_create with get. (devirtualization_time_bonus): Likewise. (ipcp_propagate_stage): Likewise. * ipa-fnsummary.c (redirect_to_unreachable): Likewise. (edge_set_predicate): Likewise. (evaluate_conditions_for_known_args): Likewise. (evaluate_properties_for_edge): Likewise. (ipa_call_summary::reset): Tranform to ... (ipa_call_summary::~ipa_call_summary): ... this. (ipa_fn_summary::reset): Transform to ... (ipa_fn_summary::~ipa_fn_summary): ... this. (ipa_fn_summary_t::remove): Rename to ... (ipa_fn_summary_t::remove_callees): ... this. (ipa_fn_summary_t::duplicate): Use placement new instead of memory copy. (ipa_call_summary_t::duplicate): Likewise. (ipa_call_summary_t::remove): Remove. (dump_ipa_call_summary): Change get_create to get. (ipa_dump_fn_summary): Dump only when summary exists. (analyze_function_body): Use symbol_summary::get instead of get_create. (compute_fn_summary): Likewise. (estimate_edge_devirt_benefit): Likewise. (estimate_edge_size_and_time): Likewise. (inline_update_callee_summaries): Likewise. (remap_edge_change_prob): Likewise. (remap_edge_summaries): Likewise. (ipa_merge_fn_summary_after_inlining): Likewise. (write_ipa_call_summary): Likewise. (ipa_fn_summary_write): Likewise. (ipa_free_fn_summary): Likewise. * ipa-fnsummary.h (struct GTY): Add new ctor and copy ctor. (struct ipa_call_summary): Likewise. * ipa-icf.c (sem_function::merge): Use symbol_summary::get instead of get_create. * ipa-inline-analysis.c (do_estimate_edge_time): Likewise. (estimate_size_after_inlining): Likewise. (estimate_growth): Likewise. (growth_likely_positive): Likewise. * ipa-inline-transform.c (clone_inlined_nodes): Likewise. (inline_call): Likewise. * ipa-inline.c (caller_growth_limits): Likewise. (can_inline_edge_p): Likewise. (can_inline_edge_by_limits_p): Likewise. (compute_uninlined_call_time): Likewise. (compute_inlined_call_time): Likewise. (want_inline_small_function_p): Likewise. (edge_badness): Likewise. (update_caller_keys): Likewise. (update_callee_keys): Likewise. (inline_small_functions): Likewise. (inline_to_all_callers_1): Likewise. (dump_overall_stats): Likewise. (early_inline_small_functions): Likewise. (early_inliner): Likewise. * ipa-profile.c (ipa_propagate_frequency_1): Likewise. * ipa-prop.c (ipa_make_edge_direct_to_target): Likewise. * ipa-pure-const.c (malloc_candidate_p): Likewise. * ipa-split.c (execute_split_functions): Likewise. * symbol-summary.h: Likewise. * tree-sra.c (ipa_sra_preliminary_function_checks): Likewise. 2018-06-19 Martin Liska <mliska@suse.cz> * lto-partition.c (add_symbol_to_partition_1): Use symbol_summary::get instead of get_create. (undo_partition): Likewise. (lto_balanced_map): Likewise. From-SVN: r261744
Diffstat (limited to 'gcc/ipa-inline.c')
-rw-r--r--gcc/ipa-inline.c89
1 files changed, 52 insertions, 37 deletions
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index 7e4468a..a62c1ff 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -151,7 +151,7 @@ caller_growth_limits (struct cgraph_edge *e)
int limit = 0;
HOST_WIDE_INT stack_size_limit = 0, inlined_stack;
ipa_fn_summary *info, *what_info;
- ipa_fn_summary *outer_info = ipa_fn_summaries->get_create (to);
+ ipa_fn_summary *outer_info = ipa_fn_summaries->get (to);
/* Look for function e->caller is inlined to. While doing
so work out the largest function body on the way. As
@@ -163,7 +163,7 @@ caller_growth_limits (struct cgraph_edge *e)
too much in order to prevent compiler from exploding". */
while (true)
{
- info = ipa_fn_summaries->get_create (to);
+ info = ipa_fn_summaries->get (to);
if (limit < info->self_size)
limit = info->self_size;
if (stack_size_limit < info->estimated_self_stack_size)
@@ -174,7 +174,7 @@ caller_growth_limits (struct cgraph_edge *e)
break;
}
- what_info = ipa_fn_summaries->get_create (what);
+ what_info = ipa_fn_summaries->get (what);
if (limit < what_info->self_size)
limit = what_info->self_size;
@@ -364,7 +364,8 @@ can_inline_edge_p (struct cgraph_edge *e, bool report,
e->inline_failed = CIF_TARGET_OPTION_MISMATCH;
inlinable = false;
}
- else if (!ipa_fn_summaries->get_create (callee)->inlinable)
+ else if (ipa_fn_summaries->get (callee) == NULL
+ || !ipa_fn_summaries->get (callee)->inlinable)
{
e->inline_failed = CIF_FUNCTION_NOT_INLINABLE;
inlinable = false;
@@ -426,8 +427,8 @@ can_inline_edge_by_limits_p (struct cgraph_edge *e, bool report,
(DECL_DISREGARD_INLINE_LIMITS (callee->decl)
&& lookup_attribute ("always_inline",
DECL_ATTRIBUTES (callee->decl)));
- ipa_fn_summary *caller_info = ipa_fn_summaries->get_create (caller);
- ipa_fn_summary *callee_info = ipa_fn_summaries->get_create (callee);
+ ipa_fn_summary *caller_info = ipa_fn_summaries->get (caller);
+ ipa_fn_summary *callee_info = ipa_fn_summaries->get (callee);
/* Until GCC 4.9 we did not check the semantics alterning flags
bellow and inline across optimization boundry.
@@ -530,7 +531,7 @@ can_inline_edge_by_limits_p (struct cgraph_edge *e, bool report,
> opt_for_fn (caller->decl, optimize)))
{
if (estimate_edge_time (e)
- >= 20 + ipa_call_summaries->get_create (e)->call_stmt_time)
+ >= 20 + ipa_call_summaries->get (e)->call_stmt_time)
{
e->inline_failed = CIF_OPTIMIZATION_MISMATCH;
inlinable = false;
@@ -680,7 +681,7 @@ compute_uninlined_call_time (struct cgraph_edge *edge,
else
uninlined_call_time = uninlined_call_time >> 11;
- sreal caller_time = ipa_fn_summaries->get_create (caller)->time;
+ sreal caller_time = ipa_fn_summaries->get (caller)->time;
return uninlined_call_time + caller_time;
}
@@ -694,7 +695,7 @@ compute_inlined_call_time (struct cgraph_edge *edge,
cgraph_node *caller = (edge->caller->global.inlined_to
? edge->caller->global.inlined_to
: edge->caller);
- sreal caller_time = ipa_fn_summaries->get_create (caller)->time;
+ sreal caller_time = ipa_fn_summaries->get (caller)->time;
sreal freq = edge->sreal_frequency ();
if (freq > 0)
@@ -704,7 +705,7 @@ compute_inlined_call_time (struct cgraph_edge *edge,
/* This calculation should match one in ipa-inline-analysis.c
(estimate_edge_size_and_time). */
- time -= (sreal)ipa_call_summaries->get_create (edge)->call_stmt_time * freq;
+ time -= (sreal)ipa_call_summaries->get (edge)->call_stmt_time * freq;
time += caller_time;
if (time <= 0)
time = ((sreal) 1) >> 8;
@@ -756,8 +757,8 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
MAX_INLINE_INSNS_SINGLE 16-fold for inline functions. */
else if ((!DECL_DECLARED_INLINE_P (callee->decl)
&& (!e->count.ipa ().initialized_p () || !e->maybe_hot_p ()))
- && ipa_fn_summaries->get_create (callee)->min_size
- - ipa_call_summaries->get_create (e)->call_stmt_size
+ && ipa_fn_summaries->get (callee)->min_size
+ - ipa_call_summaries->get (e)->call_stmt_size
> MAX (MAX_INLINE_INSNS_SINGLE, MAX_INLINE_INSNS_AUTO))
{
e->inline_failed = CIF_MAX_INLINE_INSNS_AUTO_LIMIT;
@@ -765,8 +766,8 @@ want_inline_small_function_p (struct cgraph_edge *e, bool report)
}
else if ((DECL_DECLARED_INLINE_P (callee->decl)
|| e->count.ipa ().nonzero_p ())
- && ipa_fn_summaries->get_create (callee)->min_size
- - ipa_call_summaries->get_create (e)->call_stmt_size
+ && ipa_fn_summaries->get (callee)->min_size
+ - ipa_call_summaries->get (e)->call_stmt_size
> 16 * MAX_INLINE_INSNS_SINGLE)
{
e->inline_failed = (DECL_DECLARED_INLINE_P (callee->decl)
@@ -1018,7 +1019,7 @@ edge_badness (struct cgraph_edge *edge, bool dump)
int growth;
sreal edge_time, unspec_edge_time;
struct cgraph_node *callee = edge->callee->ultimate_alias_target ();
- struct ipa_fn_summary *callee_info = ipa_fn_summaries->get_create (callee);
+ struct ipa_fn_summary *callee_info = ipa_fn_summaries->get (callee);
ipa_hints hints;
cgraph_node *caller = (edge->caller->global.inlined_to
? edge->caller->global.inlined_to
@@ -1131,7 +1132,7 @@ edge_badness (struct cgraph_edge *edge, bool dump)
&& (!DECL_DECLARED_INLINE_P (edge->callee->decl)
|| DECL_DECLARED_INLINE_P (caller->decl)))))
{
- ipa_fn_summary *caller_info = ipa_fn_summaries->get_create (caller);
+ ipa_fn_summary *caller_info = ipa_fn_summaries->get (caller);
int caller_growth = caller_info->growth;
/* Only apply the penalty when caller looks like inline candidate,
@@ -1190,7 +1191,7 @@ edge_badness (struct cgraph_edge *edge, bool dump)
of functions fully inlined in program. */
else
{
- int nest = MIN (ipa_call_summaries->get_create (edge)->loop_depth, 8);
+ int nest = MIN (ipa_call_summaries->get (edge)->loop_depth, 8);
badness = growth;
/* Decrease badness if call is nested. */
@@ -1334,7 +1335,7 @@ update_caller_keys (edge_heap_t *heap, struct cgraph_node *node,
struct cgraph_edge *edge;
struct ipa_ref *ref;
- if ((!node->alias && !ipa_fn_summaries->get_create (node)->inlinable)
+ if ((!node->alias && !ipa_fn_summaries->get (node)->inlinable)
|| node->global.inlined_to)
return;
if (!bitmap_set_bit (updated_nodes, node->get_uid ()))
@@ -1393,7 +1394,8 @@ update_callee_keys (edge_heap_t *heap, struct cgraph_node *node,
don't need updating. */
if (e->inline_failed
&& (callee = e->callee->ultimate_alias_target (&avail, e->caller))
- && ipa_fn_summaries->get_create (callee)->inlinable
+ && ipa_fn_summaries->get (callee) != NULL
+ && ipa_fn_summaries->get (callee)->inlinable
&& avail >= AVAIL_AVAILABLE
&& !bitmap_bit_p (updated_nodes, callee->get_uid ()))
{
@@ -1769,7 +1771,7 @@ inline_small_functions (void)
&& (node->has_gimple_body_p () || node->thunk.thunk_p)
&& opt_for_fn (node->decl, optimize))
{
- struct ipa_fn_summary *info = ipa_fn_summaries->get_create (node);
+ struct ipa_fn_summary *info = ipa_fn_summaries->get (node);
struct ipa_dfs_info *dfs = (struct ipa_dfs_info *) node->aux;
/* Do not account external functions, they will be optimized out
@@ -1791,7 +1793,7 @@ inline_small_functions (void)
n2 = ((struct ipa_dfs_info *) n2->aux)->next_cycle)
if (opt_for_fn (n2->decl, optimize))
{
- ipa_fn_summary *info2 = ipa_fn_summaries->get_create (n2);
+ ipa_fn_summary *info2 = ipa_fn_summaries->get (n2);
if (info2->scc_no)
break;
info2->scc_no = id;
@@ -1952,7 +1954,7 @@ inline_small_functions (void)
fprintf (dump_file,
"\nConsidering %s with %i size\n",
callee->dump_name (),
- ipa_fn_summaries->get_create (callee)->size);
+ ipa_fn_summaries->get (callee)->size);
fprintf (dump_file,
" to be inlined into %s in %s:%i\n"
" Estimated badness is %f, frequency %.2f.\n",
@@ -2078,7 +2080,7 @@ inline_small_functions (void)
if (dump_file)
{
- ipa_fn_summary *s = ipa_fn_summaries->get_create (edge->caller);
+ ipa_fn_summary *s = ipa_fn_summaries->get (edge->caller);
fprintf (dump_file,
" Inlined %s into %s which now has time %f and size %i, "
"net change of %+i.\n",
@@ -2220,11 +2222,11 @@ inline_to_all_callers_1 (struct cgraph_node *node, void *data,
fprintf (dump_file,
"\nInlining %s size %i.\n",
node->name (),
- ipa_fn_summaries->get_create (node)->size);
+ ipa_fn_summaries->get (node)->size);
fprintf (dump_file,
" Called once from %s %i insns.\n",
node->callers->caller->name (),
- ipa_fn_summaries->get_create (node->callers->caller)->size);
+ ipa_fn_summaries->get (node->callers->caller)->size);
}
/* Remember which callers we inlined to, delaying updating the
@@ -2235,7 +2237,7 @@ inline_to_all_callers_1 (struct cgraph_node *node, void *data,
fprintf (dump_file,
" Inlined into %s which now has %i size\n",
caller->name (),
- ipa_fn_summaries->get_create (caller)->size);
+ ipa_fn_summaries->get (caller)->size);
if (!(*num_calls)--)
{
if (dump_file)
@@ -2276,10 +2278,13 @@ dump_overall_stats (void)
if (!node->global.inlined_to
&& !node->alias)
{
- sreal time = ipa_fn_summaries->get_create (node)->time;
- sum += time;
- if (node->count.ipa ().initialized_p ())
- sum_weighted += time * node->count.ipa ().to_gcov_type ();
+ ipa_fn_summary *s = ipa_fn_summaries->get (node);
+ if (s != NULL)
+ {
+ sum += s->time;
+ if (node->count.ipa ().initialized_p ())
+ sum_weighted += s->time * node->count.ipa ().to_gcov_type ();
+ }
}
fprintf (dump_file, "Overall time estimate: "
"%f weighted by profile: "
@@ -2655,8 +2660,12 @@ early_inline_small_functions (struct cgraph_node *node)
for (e = node->callees; e; e = e->next_callee)
{
struct cgraph_node *callee = e->callee->ultimate_alias_target ();
- if (!ipa_fn_summaries->get_create (callee)->inlinable
- || !e->inline_failed)
+
+ /* We can enounter not-yet-analyzed function during
+ early inlining on callgraphs with strongly
+ connected components. */
+ ipa_fn_summary *s = ipa_fn_summaries->get (callee);
+ if (s == NULL || !s->inlinable || !e->inline_failed)
continue;
/* Do not consider functions not declared inline. */
@@ -2765,6 +2774,9 @@ early_inliner (function *fun)
statements that don't have inline parameters computed. */
for (edge = node->callees; edge; edge = edge->next_callee)
{
+ /* We can enounter not-yet-analyzed function during
+ early inlining on callgraphs with strongly
+ connected components. */
ipa_call_summary *es = ipa_call_summaries->get_create (edge);
es->call_stmt_size
= estimate_num_insns (edge->call_stmt, &eni_size_weights);
@@ -2790,11 +2802,14 @@ early_inliner (function *fun)
for (edge = node->callees; edge; edge = edge->next_callee)
{
/* We have no summary for new bound store calls yet. */
- ipa_call_summary *es = ipa_call_summaries->get_create (edge);
- es->call_stmt_size
- = estimate_num_insns (edge->call_stmt, &eni_size_weights);
- es->call_stmt_time
- = estimate_num_insns (edge->call_stmt, &eni_time_weights);
+ ipa_call_summary *es = ipa_call_summaries->get (edge);
+ if (es != NULL)
+ {
+ es->call_stmt_size
+ = estimate_num_insns (edge->call_stmt, &eni_size_weights);
+ es->call_stmt_time
+ = estimate_num_insns (edge->call_stmt, &eni_time_weights);
+ }
if (edge->callee->decl
&& !gimple_check_call_matching_types (