mirror of git://gcc.gnu.org/git/gcc.git
ipa-inline.c/tree-inline.c: port from fprintf to dump API (PR ipa/86395)
This patch ports various fprintf calls in the inlining code to using the dump API, using the %C format code for printing cgraph_node *. I focussed on the dump messages that seemed most significant to end-users; I didn't port all of the calls. Doing so makes this information appear in -fopt-info and in optimization records, rather than just in the dump_file. It also changes the affected dumpfile-dumps from being unconditional (assuming the dump_file is enabled) to being guarded by the MSG_* status. Hence various tests with dg-final scan-*-dump directives need to gain "-all" or "-optimized" suffixes to -fdump-ipa-inline. The use of %C throughout also slightly changes the dump format for several messages, e.g. changing: Inlining void inline_me(char*) into int main(int, char**). to: ../../src/gcc/testsuite/g++.dg/tree-ssa/inline-1.C:13:8: optimized: Inlining void inline_me(char*)/0 into int main(int, char**)/2. amongst other things adding "/order" suffixes to the cgraph node names. gcc/ChangeLog: PR ipa/86395 * doc/invoke.texi (-fdump-ipa-): Document the "-optimized", "-missed", "-note", and "-all" sub-options. * ipa-inline.c (caller_growth_limits): Port from fprintf to dump API. (can_early_inline_edge_p): Likewise. (want_early_inline_function_p): Likewise. (want_inline_self_recursive_call_p): Likewise. (recursive_inlining): Likewise. (inline_small_functions): Likewise. (flatten_function): Likewise. (ipa_inline): Likewise. (inline_always_inline_functions): Likewise. (early_inline_small_functions): Likewise. (early_inliner): Likewise. * tree-inline.c (expand_call_inline): Likewise. gcc/testsuite/ChangeLog: PR ipa/86395 * g++.dg/ipa/devirt-12.C: Add "-all" suffix to "-fdump-ipa-inline". * g++.dg/ipa/imm-devirt-1.C: Add "-optimized" suffix to "-fdump-tree-einline". * g++.dg/tree-prof/inline_mismatch_args.C: Add "-all" suffix to "-fdump-tree-einline". * g++.dg/tree-ssa/inline-1.C: Add "-optimized" suffix to "-fdump-tree-einline". * g++.dg/tree-ssa/inline-2.C: Likewise. * g++.dg/tree-ssa/inline-3.C: Likewise. * g++.dg/tree-ssa/inline-4.C: New test, based on inline-1.C, but using "-fopt-info-inline". * gcc.dg/ipa/fopt-info-inline-1.c: New test. * gcc.dg/ipa/inline-4.c: Add "-all" suffix to "-fdump-ipa-inline". Add "-fopt-info-inline" and dg-optimized directive. * gcc.dg/ipa/inline-7.c: Add "-optimized" suffix to "-fdump-tree-einline". Add "-fopt-info-inline" and dg-optimized directive. Update scan-tree-dump-times to reflect /order suffixes. * gcc.dg/ipa/inlinehint-4.c: Update scan-tree-dump-times to reflect /order suffixes. * gcc.dg/plugin/dump-1.c: Add "-loop" to "-fopt-info-note" to avoid getting extra messages from inliner. * gcc.dg/plugin/dump-2.c: Likewise. * gcc.dg/pr26570.c: Add dg-prune-output to ignore new "function body not available" missed optimization messages. * gcc.dg/pr71969-2.c: Update scan-tree-dump-times to reflect /order suffixes. * gcc.dg/pr71969-3.c: Likewise. * gcc.dg/tree-ssa/inline-11.c: Add "-all" suffix to "-fdump-tree-einline". * gcc.dg/tree-ssa/inline-3.c: Add "-optimized" suffix to "-fdump-tree-einline". Update scan-tree-dump-times to reflect /order suffixes. * gcc.dg/tree-ssa/inline-4.c: Add "-optimized" suffix to "-fdump-tree-einline". Add "-fopt-info-inline" and dg-optimized directive. * gcc.dg/tree-ssa/inline-8.c: Add "-optimized" suffix to "-fdump-tree-einline". * gfortran.dg/pr79966.f90: Update scan-ipa-dump to reflect /order suffixes. From-SVN: r265920
This commit is contained in:
parent
204839e7c4
commit
4174a33ac6
|
|
@ -1,3 +1,22 @@
|
||||||
|
2018-11-08 David Malcolm <dmalcolm@redhat.com>
|
||||||
|
|
||||||
|
PR ipa/86395
|
||||||
|
* doc/invoke.texi (-fdump-ipa-): Document the "-optimized",
|
||||||
|
"-missed", "-note", and "-all" sub-options.
|
||||||
|
* ipa-inline.c (caller_growth_limits): Port from fprintf to dump
|
||||||
|
API.
|
||||||
|
(can_early_inline_edge_p): Likewise.
|
||||||
|
(want_early_inline_function_p): Likewise.
|
||||||
|
(want_inline_self_recursive_call_p): Likewise.
|
||||||
|
(recursive_inlining): Likewise.
|
||||||
|
(inline_small_functions): Likewise.
|
||||||
|
(flatten_function): Likewise.
|
||||||
|
(ipa_inline): Likewise.
|
||||||
|
(inline_always_inline_functions): Likewise.
|
||||||
|
(early_inline_small_functions): Likewise.
|
||||||
|
(early_inliner): Likewise.
|
||||||
|
* tree-inline.c (expand_call_inline): Likewise.
|
||||||
|
|
||||||
2018-11-08 David Malcolm <dmalcolm@redhat.com>
|
2018-11-08 David Malcolm <dmalcolm@redhat.com>
|
||||||
|
|
||||||
* pretty-print.c (pp_format): Handle %f.
|
* pretty-print.c (pp_format): Handle %f.
|
||||||
|
|
|
||||||
|
|
@ -14085,6 +14085,7 @@ instruction numbers for the links to the previous and next instructions
|
||||||
in a sequence.
|
in a sequence.
|
||||||
|
|
||||||
@item -fdump-ipa-@var{switch}
|
@item -fdump-ipa-@var{switch}
|
||||||
|
@itemx -fdump-ipa-@var{switch}-@var{options}
|
||||||
@opindex fdump-ipa
|
@opindex fdump-ipa
|
||||||
Control the dumping at various stages of inter-procedural analysis
|
Control the dumping at various stages of inter-procedural analysis
|
||||||
language tree to a file. The file name is generated by appending a
|
language tree to a file. The file name is generated by appending a
|
||||||
|
|
@ -14105,6 +14106,18 @@ Dump after function inlining.
|
||||||
|
|
||||||
@end table
|
@end table
|
||||||
|
|
||||||
|
Additionally, the options @option{-optimized}, @option{-missed},
|
||||||
|
@option{-note}, and @option{-all} can be provided, with the same meaning
|
||||||
|
as for @option{-fopt-info}, defaulting to @option{-optimized}.
|
||||||
|
|
||||||
|
For example, @option{-fdump-ipa-inline-optimized-missed} will emit
|
||||||
|
information on callsites that were inlined, along with callsites
|
||||||
|
that were not inlined.
|
||||||
|
|
||||||
|
By default, the dump will contain messages about successful
|
||||||
|
optimizations (equivalent to @option {-optimized}) together with
|
||||||
|
low-level details about the analysis.
|
||||||
|
|
||||||
@item -fdump-lang-all
|
@item -fdump-lang-all
|
||||||
@itemx -fdump-lang-@var{switch}
|
@itemx -fdump-lang-@var{switch}
|
||||||
@itemx -fdump-lang-@var{switch}-@var{options}
|
@itemx -fdump-lang-@var{switch}-@var{options}
|
||||||
|
|
|
||||||
147
gcc/ipa-inline.c
147
gcc/ipa-inline.c
|
|
@ -227,18 +227,19 @@ caller_growth_limits (struct cgraph_edge *e)
|
||||||
static void
|
static void
|
||||||
report_inline_failed_reason (struct cgraph_edge *e)
|
report_inline_failed_reason (struct cgraph_edge *e)
|
||||||
{
|
{
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
{
|
{
|
||||||
fprintf (dump_file, " not inlinable: %s -> %s, %s\n",
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
|
||||||
e->caller->dump_name (),
|
" not inlinable: %C -> %C, %s\n",
|
||||||
e->callee->dump_name (),
|
e->caller, e->callee,
|
||||||
cgraph_inline_failed_string (e->inline_failed));
|
cgraph_inline_failed_string (e->inline_failed));
|
||||||
if ((e->inline_failed == CIF_TARGET_OPTION_MISMATCH
|
if ((e->inline_failed == CIF_TARGET_OPTION_MISMATCH
|
||||||
|| e->inline_failed == CIF_OPTIMIZATION_MISMATCH)
|
|| e->inline_failed == CIF_OPTIMIZATION_MISMATCH)
|
||||||
&& e->caller->lto_file_data
|
&& e->caller->lto_file_data
|
||||||
&& e->callee->ultimate_alias_target ()->lto_file_data)
|
&& e->callee->ultimate_alias_target ()->lto_file_data)
|
||||||
{
|
{
|
||||||
fprintf (dump_file, " LTO objects: %s, %s\n",
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
|
||||||
|
" LTO objects: %s, %s\n",
|
||||||
e->caller->lto_file_data->file_name,
|
e->caller->lto_file_data->file_name,
|
||||||
e->callee->ultimate_alias_target ()->lto_file_data->file_name);
|
e->callee->ultimate_alias_target ()->lto_file_data->file_name);
|
||||||
}
|
}
|
||||||
|
|
@ -569,8 +570,9 @@ can_early_inline_edge_p (struct cgraph_edge *e)
|
||||||
if (!gimple_in_ssa_p (DECL_STRUCT_FUNCTION (e->caller->decl))
|
if (!gimple_in_ssa_p (DECL_STRUCT_FUNCTION (e->caller->decl))
|
||||||
|| !gimple_in_ssa_p (DECL_STRUCT_FUNCTION (callee->decl)))
|
|| !gimple_in_ssa_p (DECL_STRUCT_FUNCTION (callee->decl)))
|
||||||
{
|
{
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, " edge not inlinable: not in SSA form\n");
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
|
||||||
|
" edge not inlinable: not in SSA form\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!can_inline_edge_p (e, true, true)
|
if (!can_inline_edge_p (e, true, true)
|
||||||
|
|
@ -630,33 +632,33 @@ want_early_inline_function_p (struct cgraph_edge *e)
|
||||||
else if (!e->maybe_hot_p ()
|
else if (!e->maybe_hot_p ()
|
||||||
&& growth > 0)
|
&& growth > 0)
|
||||||
{
|
{
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, " will not early inline: %s->%s, "
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
|
||||||
|
" will not early inline: %C->%C, "
|
||||||
"call is cold and code would grow by %i\n",
|
"call is cold and code would grow by %i\n",
|
||||||
e->caller->dump_name (),
|
e->caller, callee,
|
||||||
callee->dump_name (),
|
|
||||||
growth);
|
growth);
|
||||||
want_inline = false;
|
want_inline = false;
|
||||||
}
|
}
|
||||||
else if (growth > PARAM_VALUE (PARAM_EARLY_INLINING_INSNS))
|
else if (growth > PARAM_VALUE (PARAM_EARLY_INLINING_INSNS))
|
||||||
{
|
{
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, " will not early inline: %s->%s, "
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
|
||||||
|
" will not early inline: %C->%C, "
|
||||||
"growth %i exceeds --param early-inlining-insns\n",
|
"growth %i exceeds --param early-inlining-insns\n",
|
||||||
e->caller->dump_name (),
|
e->caller, callee,
|
||||||
callee->dump_name (),
|
|
||||||
growth);
|
growth);
|
||||||
want_inline = false;
|
want_inline = false;
|
||||||
}
|
}
|
||||||
else if ((n = num_calls (callee)) != 0
|
else if ((n = num_calls (callee)) != 0
|
||||||
&& growth * (n + 1) > PARAM_VALUE (PARAM_EARLY_INLINING_INSNS))
|
&& growth * (n + 1) > PARAM_VALUE (PARAM_EARLY_INLINING_INSNS))
|
||||||
{
|
{
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, " will not early inline: %s->%s, "
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
|
||||||
|
" will not early inline: %C->%C, "
|
||||||
"growth %i exceeds --param early-inlining-insns "
|
"growth %i exceeds --param early-inlining-insns "
|
||||||
"divided by number of calls\n",
|
"divided by number of calls\n",
|
||||||
e->caller->dump_name (),
|
e->caller, callee,
|
||||||
callee->dump_name (),
|
|
||||||
growth);
|
growth);
|
||||||
want_inline = false;
|
want_inline = false;
|
||||||
}
|
}
|
||||||
|
|
@ -936,8 +938,9 @@ want_inline_self_recursive_call_p (struct cgraph_edge *edge,
|
||||||
want_inline = false;
|
want_inline = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!want_inline && dump_file)
|
if (!want_inline && dump_enabled_p ())
|
||||||
fprintf (dump_file, " not inlining recursively: %s\n", reason);
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, edge->call_stmt,
|
||||||
|
" not inlining recursively: %s\n", reason);
|
||||||
return want_inline;
|
return want_inline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1562,8 +1565,8 @@ recursive_inlining (struct cgraph_edge *edge,
|
||||||
if (!master_clone)
|
if (!master_clone)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file,
|
dump_printf_loc (MSG_NOTE, edge->call_stmt,
|
||||||
"\n Inlined %i times, "
|
"\n Inlined %i times, "
|
||||||
"body grown from size %i to %i, time %f to %f\n", n,
|
"body grown from size %i to %i, time %f to %f\n", n,
|
||||||
ipa_fn_summaries->get (master_clone)->size,
|
ipa_fn_summaries->get (master_clone)->size,
|
||||||
|
|
@ -2078,17 +2081,20 @@ inline_small_functions (void)
|
||||||
update_callee_keys (&edge_heap, n, updated_nodes);
|
update_callee_keys (&edge_heap, n, updated_nodes);
|
||||||
bitmap_clear (updated_nodes);
|
bitmap_clear (updated_nodes);
|
||||||
|
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
{
|
{
|
||||||
ipa_fn_summary *s = ipa_fn_summaries->get (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, "
|
/* dump_printf can't handle %+i. */
|
||||||
"net change of %+i.\n",
|
char buf_net_change[100];
|
||||||
xstrdup_for_dump (edge->callee->name ()),
|
snprintf (buf_net_change, sizeof buf_net_change, "%+i",
|
||||||
xstrdup_for_dump (edge->caller->name ()),
|
|
||||||
s->time.to_double (),
|
|
||||||
s->size,
|
|
||||||
overall_size - old_size);
|
overall_size - old_size);
|
||||||
|
|
||||||
|
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, edge->call_stmt,
|
||||||
|
" Inlined %C into %C which now has time %f and "
|
||||||
|
"size %i, net change of %s.\n",
|
||||||
|
edge->callee, edge->caller,
|
||||||
|
s->time.to_double (), s->size, buf_net_change);
|
||||||
}
|
}
|
||||||
if (min_size > overall_size)
|
if (min_size > overall_size)
|
||||||
{
|
{
|
||||||
|
|
@ -2101,8 +2107,8 @@ inline_small_functions (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
free_growth_caches ();
|
free_growth_caches ();
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file,
|
dump_printf (MSG_NOTE,
|
||||||
"Unit growth for small function inlining: %i->%i (%i%%)\n",
|
"Unit growth for small function inlining: %i->%i (%i%%)\n",
|
||||||
initial_size, overall_size,
|
initial_size, overall_size,
|
||||||
initial_size ? overall_size * 100 / (initial_size) - 100: 0);
|
initial_size ? overall_size * 100 / (initial_size) - 100: 0);
|
||||||
|
|
@ -2130,11 +2136,10 @@ flatten_function (struct cgraph_node *node, bool early)
|
||||||
/* We've hit cycle? It is time to give up. */
|
/* We've hit cycle? It is time to give up. */
|
||||||
if (callee->aux)
|
if (callee->aux)
|
||||||
{
|
{
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file,
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
|
||||||
"Not inlining %s into %s to avoid cycle.\n",
|
"Not inlining %C into %C to avoid cycle.\n",
|
||||||
xstrdup_for_dump (callee->name ()),
|
callee, e->caller);
|
||||||
xstrdup_for_dump (e->caller->name ()));
|
|
||||||
if (cgraph_inline_failed_type (e->inline_failed) != CIF_FINAL_ERROR)
|
if (cgraph_inline_failed_type (e->inline_failed) != CIF_FINAL_ERROR)
|
||||||
e->inline_failed = CIF_RECURSIVE_INLINING;
|
e->inline_failed = CIF_RECURSIVE_INLINING;
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -2159,25 +2164,27 @@ flatten_function (struct cgraph_node *node, bool early)
|
||||||
|
|
||||||
if (e->recursive_p ())
|
if (e->recursive_p ())
|
||||||
{
|
{
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, "Not inlining: recursive call.\n");
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
|
||||||
|
"Not inlining: recursive call.\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gimple_in_ssa_p (DECL_STRUCT_FUNCTION (node->decl))
|
if (gimple_in_ssa_p (DECL_STRUCT_FUNCTION (node->decl))
|
||||||
!= gimple_in_ssa_p (DECL_STRUCT_FUNCTION (callee->decl)))
|
!= gimple_in_ssa_p (DECL_STRUCT_FUNCTION (callee->decl)))
|
||||||
{
|
{
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, "Not inlining: SSA form does not match.\n");
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
|
||||||
|
"Not inlining: SSA form does not match.\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inline the edge and flatten the inline clone. Avoid
|
/* Inline the edge and flatten the inline clone. Avoid
|
||||||
recursing through the original node if the node was cloned. */
|
recursing through the original node if the node was cloned. */
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, " Inlining %s into %s.\n",
|
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, e->call_stmt,
|
||||||
xstrdup_for_dump (callee->name ()),
|
" Inlining %C into %C.\n",
|
||||||
xstrdup_for_dump (e->caller->name ()));
|
callee, e->caller);
|
||||||
orig_callee = callee;
|
orig_callee = callee;
|
||||||
inline_call (e, true, NULL, NULL, false);
|
inline_call (e, true, NULL, NULL, false);
|
||||||
if (e->callee != orig_callee)
|
if (e->callee != orig_callee)
|
||||||
|
|
@ -2589,13 +2596,12 @@ ipa_inline (void)
|
||||||
/* Free ipa-prop structures if they are no longer needed. */
|
/* Free ipa-prop structures if they are no longer needed. */
|
||||||
ipa_free_all_structures_after_iinln ();
|
ipa_free_all_structures_after_iinln ();
|
||||||
|
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
{
|
dump_printf (MSG_NOTE,
|
||||||
fprintf (dump_file,
|
|
||||||
"\nInlined %i calls, eliminated %i functions\n\n",
|
"\nInlined %i calls, eliminated %i functions\n\n",
|
||||||
ncalls_inlined, nfunctions_inlined);
|
ncalls_inlined, nfunctions_inlined);
|
||||||
|
if (dump_file)
|
||||||
dump_inline_stats ();
|
dump_inline_stats ();
|
||||||
}
|
|
||||||
|
|
||||||
if (dump_file)
|
if (dump_file)
|
||||||
ipa_dump_fn_summaries (dump_file);
|
ipa_dump_fn_summaries (dump_file);
|
||||||
|
|
@ -2618,9 +2624,10 @@ inline_always_inline_functions (struct cgraph_node *node)
|
||||||
|
|
||||||
if (e->recursive_p ())
|
if (e->recursive_p ())
|
||||||
{
|
{
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, " Not inlining recursive call to %s.\n",
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
|
||||||
e->callee->name ());
|
" Not inlining recursive call to %C.\n",
|
||||||
|
e->callee);
|
||||||
e->inline_failed = CIF_RECURSIVE_INLINING;
|
e->inline_failed = CIF_RECURSIVE_INLINING;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
@ -2636,10 +2643,10 @@ inline_always_inline_functions (struct cgraph_node *node)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, " Inlining %s into %s (always_inline).\n",
|
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, e->call_stmt,
|
||||||
xstrdup_for_dump (e->callee->name ()),
|
" Inlining %C into %C (always_inline).\n",
|
||||||
xstrdup_for_dump (e->caller->name ()));
|
e->callee, e->caller);
|
||||||
inline_call (e, true, NULL, NULL, false);
|
inline_call (e, true, NULL, NULL, false);
|
||||||
inlined = true;
|
inlined = true;
|
||||||
}
|
}
|
||||||
|
|
@ -2675,27 +2682,29 @@ early_inline_small_functions (struct cgraph_node *node)
|
||||||
&& !opt_for_fn (node->decl, flag_inline_functions))
|
&& !opt_for_fn (node->decl, flag_inline_functions))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, "Considering inline candidate %s.\n",
|
dump_printf_loc (MSG_NOTE, e->call_stmt,
|
||||||
callee->name ());
|
"Considering inline candidate %C.\n",
|
||||||
|
callee);
|
||||||
|
|
||||||
if (!can_early_inline_edge_p (e))
|
if (!can_early_inline_edge_p (e))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (e->recursive_p ())
|
if (e->recursive_p ())
|
||||||
{
|
{
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, " Not inlining: recursive call.\n");
|
dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
|
||||||
|
" Not inlining: recursive call.\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!want_early_inline_function_p (e))
|
if (!want_early_inline_function_p (e))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file, " Inlining %s into %s.\n",
|
dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, e->call_stmt,
|
||||||
xstrdup_for_dump (callee->name ()),
|
" Inlining %C into %C.\n",
|
||||||
xstrdup_for_dump (e->caller->name ()));
|
callee, e->caller);
|
||||||
inline_call (e, true, NULL, NULL, false);
|
inline_call (e, true, NULL, NULL, false);
|
||||||
inlined = true;
|
inlined = true;
|
||||||
}
|
}
|
||||||
|
|
@ -2755,9 +2764,9 @@ early_inliner (function *fun)
|
||||||
{
|
{
|
||||||
/* When the function is marked to be flattened, recursively inline
|
/* When the function is marked to be flattened, recursively inline
|
||||||
all calls in it. */
|
all calls in it. */
|
||||||
if (dump_file)
|
if (dump_enabled_p ())
|
||||||
fprintf (dump_file,
|
dump_printf (MSG_OPTIMIZED_LOCATIONS,
|
||||||
"Flattening %s\n", node->name ());
|
"Flattening %C\n", node);
|
||||||
flatten_function (node, true);
|
flatten_function (node, true);
|
||||||
inlined = true;
|
inlined = true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,49 @@
|
||||||
|
2018-11-08 David Malcolm <dmalcolm@redhat.com>
|
||||||
|
|
||||||
|
PR ipa/86395
|
||||||
|
* g++.dg/ipa/devirt-12.C: Add "-all" suffix to
|
||||||
|
"-fdump-ipa-inline".
|
||||||
|
* g++.dg/ipa/imm-devirt-1.C: Add "-optimized" suffix to
|
||||||
|
"-fdump-tree-einline".
|
||||||
|
* g++.dg/tree-prof/inline_mismatch_args.C: Add "-all" suffix to
|
||||||
|
"-fdump-tree-einline".
|
||||||
|
* g++.dg/tree-ssa/inline-1.C: Add "-optimized" suffix to
|
||||||
|
"-fdump-tree-einline".
|
||||||
|
* g++.dg/tree-ssa/inline-2.C: Likewise.
|
||||||
|
* g++.dg/tree-ssa/inline-3.C: Likewise.
|
||||||
|
* g++.dg/tree-ssa/inline-4.C: New test, based on inline-1.C, but
|
||||||
|
using "-fopt-info-inline".
|
||||||
|
* gcc.dg/ipa/fopt-info-inline-1.c: New test.
|
||||||
|
* gcc.dg/ipa/inline-4.c: Add "-all" suffix to
|
||||||
|
"-fdump-ipa-inline". Add "-fopt-info-inline" and dg-optimized
|
||||||
|
directive.
|
||||||
|
* gcc.dg/ipa/inline-7.c: Add "-optimized" suffix to
|
||||||
|
"-fdump-tree-einline". Add "-fopt-info-inline" and dg-optimized
|
||||||
|
directive. Update scan-tree-dump-times to reflect /order
|
||||||
|
suffixes.
|
||||||
|
* gcc.dg/ipa/inlinehint-4.c: Update scan-tree-dump-times to
|
||||||
|
reflect /order suffixes.
|
||||||
|
* gcc.dg/plugin/dump-1.c: Add "-loop" to "-fopt-info-note" to
|
||||||
|
avoid getting extra messages from inliner.
|
||||||
|
* gcc.dg/plugin/dump-2.c: Likewise.
|
||||||
|
* gcc.dg/pr26570.c: Add dg-prune-output to ignore new
|
||||||
|
"function body not available" missed optimization messages.
|
||||||
|
* gcc.dg/pr71969-2.c: Update scan-tree-dump-times to reflect
|
||||||
|
/order suffixes.
|
||||||
|
* gcc.dg/pr71969-3.c: Likewise.
|
||||||
|
* gcc.dg/tree-ssa/inline-11.c: Add "-all" suffix to
|
||||||
|
"-fdump-tree-einline".
|
||||||
|
* gcc.dg/tree-ssa/inline-3.c: Add "-optimized" suffix to
|
||||||
|
"-fdump-tree-einline". Update scan-tree-dump-times to reflect
|
||||||
|
/order suffixes.
|
||||||
|
* gcc.dg/tree-ssa/inline-4.c: Add "-optimized" suffix to
|
||||||
|
"-fdump-tree-einline". Add "-fopt-info-inline" and dg-optimized
|
||||||
|
directive.
|
||||||
|
* gcc.dg/tree-ssa/inline-8.c: Add "-optimized" suffix to
|
||||||
|
"-fdump-tree-einline".
|
||||||
|
* gfortran.dg/pr79966.f90: Update scan-ipa-dump to reflect /order
|
||||||
|
suffixes.
|
||||||
|
|
||||||
2018-11-08 David Malcolm <dmalcolm@redhat.com>
|
2018-11-08 David Malcolm <dmalcolm@redhat.com>
|
||||||
|
|
||||||
* gcc.dg/format/gcc_diag-10.c: Add coverage for %f.
|
* gcc.dg/format/gcc_diag-10.c: Add coverage for %f.
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
// { dg-do compile { target c++11 } }
|
// { dg-do compile { target c++11 } }
|
||||||
// { dg-options "-O -fdump-ipa-inline" }
|
// { dg-options "-O -fdump-ipa-inline-all" }
|
||||||
|
|
||||||
class Foo
|
class Foo
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/* Verify that virtual calls are folded even early inlining puts them into one
|
/* Verify that virtual calls are folded even early inlining puts them into one
|
||||||
function with the definition. */
|
function with the definition. */
|
||||||
/* { dg-do run } */
|
/* { dg-do run } */
|
||||||
/* { dg-options "-O2 -fdump-tree-einline" } */
|
/* { dg-options "-O2 -fdump-tree-einline-optimized" } */
|
||||||
|
|
||||||
extern "C" void abort (void);
|
extern "C" void abort (void);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
/* { dg-options "-O2 -fdump-tree-einline" } */
|
/* { dg-options "-O2 -fdump-tree-einline-all" } */
|
||||||
class DocId {
|
class DocId {
|
||||||
public:
|
public:
|
||||||
DocId() { }
|
DocId() { }
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-options "-O2 -fdump-tree-einline --param max-early-inliner-iterations=3" } */
|
/* { dg-options "-O2 -fdump-tree-einline-optimized --param max-early-inliner-iterations=3" } */
|
||||||
/* { dg-add-options bind_pic_locally } */
|
/* { dg-add-options bind_pic_locally } */
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-options "-O2 -fdump-tree-einline --param max-early-inliner-iterations=3" } */
|
/* { dg-options "-O2 -fdump-tree-einline-optimized --param max-early-inliner-iterations=3" } */
|
||||||
/* { dg-add-options bind_pic_locally } */
|
/* { dg-add-options bind_pic_locally } */
|
||||||
|
|
||||||
namespace std {
|
namespace std {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-options "-O2 -fdump-tree-einline --param max-early-inliner-iterations=5" } */
|
/* { dg-options "-O2 -fdump-tree-einline-optimized --param max-early-inliner-iterations=5" } */
|
||||||
/* { dg-add-options bind_pic_locally } */
|
/* { dg-add-options bind_pic_locally } */
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
/* { dg-do compile } */
|
||||||
|
/* { dg-options "-O2 -fopt-info-inline --param max-early-inliner-iterations=3" } */
|
||||||
|
/* { dg-add-options bind_pic_locally } */
|
||||||
|
|
||||||
|
namespace std {
|
||||||
|
extern "C" int puts(const char *s);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T, class E> void
|
||||||
|
foreach (T b, T e, void (*ptr)(E))
|
||||||
|
{
|
||||||
|
for (; b != e; b++)
|
||||||
|
ptr(*b); // { dg-optimized "Inlining void inline_me\[^\\n\]* into int main\[^\\n\]*" }
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
inline_me (char *x)
|
||||||
|
{
|
||||||
|
std::puts(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
inline_me_too (char *x)
|
||||||
|
{
|
||||||
|
std::puts(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
foreach (argv, argv + argc, inline_me); // { dg-optimized "Inlining void foreach\[^\\n\]* into int main\[^\\n\]*" }
|
||||||
|
foreach (argv, argv + argc, inline_me_too); // { dg-optimized "Inlining void foreach\[^\\n\]* into int main\[^\\n\]*" }
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,44 @@
|
||||||
|
/* { dg-options "-O3 -fopt-info-inline-optimized-missed" } */
|
||||||
|
|
||||||
|
static int foo (int a)
|
||||||
|
{
|
||||||
|
return a + 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int bar (int b)
|
||||||
|
{
|
||||||
|
return b - 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int boo (int a, int b)
|
||||||
|
{
|
||||||
|
return (foo (a) /* { dg-optimized "Inlining foo/\[0-9\]+ into boo/\[0-9\]+" } */
|
||||||
|
+ bar (b)); /* { dg-optimized "Inlining bar/\[0-9\]+ into boo/\[0-9\]+" } */
|
||||||
|
}
|
||||||
|
|
||||||
|
extern int v_a, v_b;
|
||||||
|
extern int result;
|
||||||
|
|
||||||
|
int compute ()
|
||||||
|
{
|
||||||
|
result = boo (v_a, v_b); /* { dg-optimized "Inlining boo/\[0-9\]+ into compute/\[0-9\]+" } */
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void not_available(int);
|
||||||
|
|
||||||
|
int __attribute__ ((noinline,noclone)) get_input(void)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int test_1 ()
|
||||||
|
{
|
||||||
|
return get_input (); /* { dg-missed "not inlinable: test_1/\[0-9\]+ -> get_input/\[0-9\]+, function not inlinable" } */
|
||||||
|
}
|
||||||
|
|
||||||
|
void test_2 (int v)
|
||||||
|
{
|
||||||
|
not_available (1); /* { dg-missed "not inlinable: test_2/\[0-9\]+ -> not_available/\[0-9\]+, function body not available" } */
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-options "-Os -c -fdump-ipa-inline -fno-early-inlining -fno-partial-inlining -fno-ipa-cp" } */
|
/* { dg-options "-Os -c -fdump-ipa-inline-all -fopt-info-inline -fno-early-inlining -fno-partial-inlining -fno-ipa-cp" } */
|
||||||
/* { dg-add-options bind_pic_locally } */
|
/* { dg-add-options bind_pic_locally } */
|
||||||
|
|
||||||
void work_hard (void);
|
void work_hard (void);
|
||||||
|
|
@ -20,7 +20,7 @@ void do_something (int shall_i_work)
|
||||||
}
|
}
|
||||||
int foo (int invariant)
|
int foo (int invariant)
|
||||||
{
|
{
|
||||||
do_something (0);
|
do_something (0); // { dg-optimized "Inlined do_something/\[0-9]+ into foo/\[0-9]+" }
|
||||||
do_something (1);
|
do_something (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* Check that early inliner works out that a is empty of parameter 0. */
|
/* Check that early inliner works out that a is empty of parameter 0. */
|
||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-options "-O2 -fdump-tree-einline -fno-partial-inlining" } */
|
/* { dg-options "-O2 -fdump-tree-einline-optimized -fopt-info-inline -fno-partial-inlining" } */
|
||||||
void t(void);
|
void t(void);
|
||||||
int a (int b)
|
int a (int b)
|
||||||
{
|
{
|
||||||
|
|
@ -18,7 +18,7 @@ int a (int b)
|
||||||
void
|
void
|
||||||
m()
|
m()
|
||||||
{
|
{
|
||||||
a(1);
|
a(1); /* { dg-optimized "Inlining a/\[0-9\]* into m/\[0-9\]*" } */
|
||||||
a(0);
|
a(0);
|
||||||
}
|
}
|
||||||
/* { dg-final { scan-tree-dump-times "Inlining a into m" 1 "einline" } } */
|
/* { dg-final { scan-tree-dump-times "Inlining a.* into m.*" 1 "einline" } } */
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,5 @@ test (int i)
|
||||||
lookup (9 * i);
|
lookup (9 * i);
|
||||||
}
|
}
|
||||||
/* { dg-final { scan-ipa-dump "Wrapper penalty" "inline" } } */
|
/* { dg-final { scan-ipa-dump "Wrapper penalty" "inline" } } */
|
||||||
/* { dg-final { scan-ipa-dump-not "Inlined lookup_slow into lookup" "inline" } } */
|
/* { dg-final { scan-ipa-dump-not "Inlined lookup_slow/\[0-9\]* into lookup/\[0-9\]*" "inline" } } */
|
||||||
/* { dg-final { scan-ipa-dump "Inlined lookup into test" "inline" } } */
|
/* { dg-final { scan-ipa-dump "Inlined lookup/\[0-9\]* into test/\[0-9\]*" "inline" } } */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-options "-fopt-info-note" } */
|
/* { dg-options "-fopt-info-loop-note" } */
|
||||||
|
|
||||||
extern void test_string_literal (void);
|
extern void test_string_literal (void);
|
||||||
extern void test_tree (void);
|
extern void test_tree (void);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-options "-fopt-info-note-internals" } */
|
/* { dg-options "-fopt-info-loop-note-internals" } */
|
||||||
|
|
||||||
extern void test_string_literal (void);
|
extern void test_string_literal (void);
|
||||||
extern void test_tree (void);
|
extern void test_tree (void);
|
||||||
|
|
|
||||||
|
|
@ -6,3 +6,4 @@ unsigned test (unsigned a, unsigned b)
|
||||||
{
|
{
|
||||||
return a / b;
|
return a / b;
|
||||||
} /* { dg-missed "\[^\n\]*execution counts estimated" } */
|
} /* { dg-missed "\[^\n\]*execution counts estimated" } */
|
||||||
|
/* { dg-prune-output "function body not available" } */
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,4 @@ main ()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* { dg-final { scan-tree-dump-times "Inlining foo into main" 4 "einline" } } */
|
/* { dg-final { scan-tree-dump-times "Inlining foo/\[0-9\]* into main/\[0-9\]*" 4 "einline" } } */
|
||||||
|
|
|
||||||
|
|
@ -35,4 +35,4 @@ main ()
|
||||||
}
|
}
|
||||||
|
|
||||||
/* { dg-final { scan-tree-dump-times "will not early inline" 8 "einline" } } */
|
/* { dg-final { scan-tree-dump-times "will not early inline" 8 "einline" } } */
|
||||||
/* { dg-final { scan-tree-dump-times "Inlining foo into main" 4 "einline" } } */
|
/* { dg-final { scan-tree-dump-times "Inlining foo/\[0-9\]* into main/\[0-9\]*" 4 "einline" } } */
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-require-weak "" } */
|
/* { dg-require-weak "" } */
|
||||||
/* { dg-options "-O2 -fdump-tree-einline" } */
|
/* { dg-options "-O2 -fdump-tree-einline-all" } */
|
||||||
int w;
|
int w;
|
||||||
int bar (void) __attribute__ ((weak));
|
int bar (void) __attribute__ ((weak));
|
||||||
int bar (){
|
int bar (){
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-options "-O2 -fdump-tree-einline --param max-early-inliner-iterations=2" } */
|
/* { dg-options "-O2 -fdump-tree-einline-optimized --param max-early-inliner-iterations=2" } */
|
||||||
/* { dg-add-options bind_pic_locally } */
|
/* { dg-add-options bind_pic_locally } */
|
||||||
|
|
||||||
extern void inlined ();
|
extern void inlined ();
|
||||||
|
|
@ -27,5 +27,5 @@ inline_me_too (void)
|
||||||
{
|
{
|
||||||
inlined();
|
inlined();
|
||||||
}
|
}
|
||||||
/* { dg-final { scan-tree-dump-times "Inlining inline_me " 1 "einline"} } */
|
/* { dg-final { scan-tree-dump-times "Inlining inline_me/\[0-9\]* " 1 "einline"} } */
|
||||||
/* { dg-final { scan-tree-dump-times "Inlining inline_me_too " 1 "einline"} } */
|
/* { dg-final { scan-tree-dump-times "Inlining inline_me_too/\[0-9\]* " 1 "einline"} } */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-options "-O2 -fdump-tree-einline" } */
|
/* { dg-options "-O2 -fdump-tree-einline-optimized -fopt-info-inline" } */
|
||||||
/* { dg-add-options bind_pic_locally } */
|
/* { dg-add-options bind_pic_locally } */
|
||||||
|
|
||||||
extern int rand(void);
|
extern int rand(void);
|
||||||
|
|
@ -13,7 +13,7 @@ int my_id;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
int res = get_data_for (my_id);
|
int res = get_data_for (my_id); /* { dg-optimized "Inlining get_data_for/\[0-9\]+ into main/\[0-9\]+." } */
|
||||||
switch (res)
|
switch (res)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
|
|
@ -23,4 +23,4 @@ int main()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* { dg-final { scan-tree-dump "Inlining get_data_for into main" "einline" } } */
|
/* { dg-final { scan-tree-dump "Inlining get_data_for/\[0-9\]* into main/\[0-9\]*" "einline" } } */
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
/* { dg-do compile } */
|
/* { dg-do compile } */
|
||||||
/* { dg-options "-O -finline-small-functions --param early-inlining-insns=0 -fdump-tree-einline" } */
|
/* { dg-options "-O -finline-small-functions --param early-inlining-insns=0 -fdump-tree-einline-optimized" } */
|
||||||
|
|
||||||
int foo0();
|
int foo0();
|
||||||
void bar0() { foo0(); }
|
void bar0() { foo0(); }
|
||||||
|
|
|
||||||
|
|
@ -109,4 +109,4 @@ contains
|
||||||
call RunTPTests()
|
call RunTPTests()
|
||||||
end program
|
end program
|
||||||
|
|
||||||
! { dg-final { scan-ipa-dump "Inlined tp_sum into runtptests" "inline" } }
|
! { dg-final { scan-ipa-dump "Inlined tp_sum/\[0-9\]+ into runtptests/\[0-9\]+" "inline" } }
|
||||||
|
|
|
||||||
|
|
@ -4673,15 +4673,21 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
|
||||||
/* Add local vars in this inlined callee to caller. */
|
/* Add local vars in this inlined callee to caller. */
|
||||||
add_local_variables (id->src_cfun, cfun, id);
|
add_local_variables (id->src_cfun, cfun, id);
|
||||||
|
|
||||||
|
if (dump_enabled_p ())
|
||||||
|
{
|
||||||
|
char buf[128];
|
||||||
|
snprintf (buf, sizeof(buf), "%4.2f",
|
||||||
|
cg_edge->sreal_frequency ().to_double ());
|
||||||
|
dump_printf_loc (MSG_NOTE | MSG_PRIORITY_INTERNALS,
|
||||||
|
call_stmt,
|
||||||
|
"Inlining %C to %C with frequency %s\n",
|
||||||
|
id->src_node, id->dst_node, buf);
|
||||||
if (dump_file && (dump_flags & TDF_DETAILS))
|
if (dump_file && (dump_flags & TDF_DETAILS))
|
||||||
{
|
{
|
||||||
fprintf (dump_file, "Inlining %s to %s with frequency %4.2f\n",
|
|
||||||
id->src_node->dump_name (),
|
|
||||||
id->dst_node->dump_name (),
|
|
||||||
cg_edge->sreal_frequency ().to_double ());
|
|
||||||
id->src_node->dump (dump_file);
|
id->src_node->dump (dump_file);
|
||||||
id->dst_node->dump (dump_file);
|
id->dst_node->dump (dump_file);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* This is it. Duplicate the callee body. Assume callee is
|
/* This is it. Duplicate the callee body. Assume callee is
|
||||||
pre-gimplified. Note that we must not alter the caller
|
pre-gimplified. Note that we must not alter the caller
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue