@@ -120,6 +120,7 @@ along with GCC; see the file COPYING3. If not see
#include "stringpool.h"
#include "attribs.h"
#include "asan.h"
+#include "optinfo.h"
typedef fibonacci_heap <sreal, cgraph_edge> edge_heap_t;
typedef fibonacci_node <sreal, cgraph_edge> edge_heap_node_t;
@@ -227,20 +228,21 @@ caller_growth_limits (struct cgraph_edge *e)
static void
report_inline_failed_reason (struct cgraph_edge *e)
{
- if (dump_file)
+ if (dump_enabled_p ())
{
- fprintf (dump_file, " not inlinable: %s -> %s, %s\n",
- e->caller->dump_name (),
- e->callee->dump_name (),
- cgraph_inline_failed_string (e->inline_failed));
+ dump_printf_loc (MSG_MISSED_OPTIMIZATION, e->call_stmt,
+ " not inlinable: %s -> %s, %s\n",
+ e->caller->dump_name (),
+ e->callee->dump_name (),
+ cgraph_inline_failed_string (e->inline_failed));
if ((e->inline_failed == CIF_TARGET_OPTION_MISMATCH
|| e->inline_failed == CIF_OPTIMIZATION_MISMATCH)
&& e->caller->lto_file_data
&& e->callee->ultimate_alias_target ()->lto_file_data)
{
- fprintf (dump_file, " LTO objects: %s, %s\n",
- e->caller->lto_file_data->file_name,
- e->callee->ultimate_alias_target ()->lto_file_data->file_name);
+ dump_printf (MSG_MISSED_OPTIMIZATION, " LTO objects: %s, %s\n",
+ e->caller->lto_file_data->file_name,
+ e->callee->ultimate_alias_target ()->lto_file_data->file_name);
}
if (e->inline_failed == CIF_TARGET_OPTION_MISMATCH)
cl_target_option_print_diff
@@ -2172,10 +2174,11 @@ flatten_function (struct cgraph_node *node, bool early)
/* Inline the edge and flatten the inline clone. Avoid
recursing through the original node if the node was cloned. */
- if (dump_file)
- fprintf (dump_file, " Inlining %s into %s.\n",
- xstrdup_for_dump (callee->name ()),
- xstrdup_for_dump (e->caller->name ()));
+ if (dump_enabled_p ())
+ dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, e->call_stmt,
+ " Inlining %s into %s.\n",
+ xstrdup_for_dump (callee->name ()),
+ xstrdup_for_dump (e->caller->name ()));
orig_callee = callee;
inline_call (e, true, NULL, NULL, false);
if (e->callee != orig_callee)
@@ -2682,10 +2685,32 @@ early_inline_small_functions (struct cgraph_node *node)
if (!want_early_inline_function_p (e))
continue;
- if (dump_file)
- fprintf (dump_file, " Inlining %s into %s.\n",
- xstrdup_for_dump (callee->name ()),
- xstrdup_for_dump (e->caller->name ()));
+ /* FIXME: if (dump_enabled_p ()) would be simpler. */
+ if (optinfo_guard guard = optinfo_guard (e->call_stmt,
+ OPTINFO_IMPL_LOCATION))
+ {
+ if (1)
+ {
+ /* Use of dump_symtab_node, which thus captures the nodes
+ in the optimization record. */
+ dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, e->call_stmt,
+ " Inlining ");
+ dump_symtab_node (MSG_OPTIMIZED_LOCATIONS, callee);
+ dump_printf (MSG_OPTIMIZED_LOCATIONS,
+ " into ");
+ dump_symtab_node (MSG_OPTIMIZED_LOCATIONS, e->caller);
+ dump_printf (MSG_OPTIMIZED_LOCATIONS, ".\n");
+ }
+ else
+ {
+ /* printf-style printing, which doesn't capture the
+ symtab_nodes themselves. */
+ dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, e->call_stmt,
+ " Inlining %s into %s.\n",
+ xstrdup_for_dump (callee->name ()),
+ xstrdup_for_dump (e->caller->name ()));
+ }
+ }
inline_call (e, true, NULL, NULL, false);
inlined = true;
}
@@ -4627,14 +4627,18 @@ expand_call_inline (basic_block bb, gimple *stmt, copy_body_data *id)
/* Add local vars in this inlined callee to caller. */
add_local_variables (id->src_cfun, cfun, id);
- if (dump_file && (dump_flags & TDF_DETAILS))
+ if (dump_enabled_p ())
{
- 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->dst_node->dump (dump_file);
+ dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, call_stmt,
+ "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 ());
+ if (dump_file && (dump_flags & TDF_DETAILS))
+ {
+ id->src_node->dump (dump_file);
+ id->dst_node->dump (dump_file);
+ }
}
/* This is it. Duplicate the callee body. Assume callee is