Commit 38bc76da by Richard Guenther Committed by Richard Biener

re PR middle-end/37448 (cannot compile big function)

2010-01-29  Richard Guenther  <rguenther@suse.de>

	PR middle-end/37448
	* ipa-inline.c (cgraph_decide_inlining_incrementally): Avoid
	quadratic behavior in most cases.

From-SVN: r156343
parent 9ee5ebeb
2010-01-29 Richard Guenther <rguenther@suse.de>
PR middle-end/37448
* ipa-inline.c (cgraph_decide_inlining_incrementally): Avoid
quadratic behavior in most cases.
2010-01-28 Uros Bizjak <ubizjak@gmail.com> 2010-01-28 Uros Bizjak <ubizjak@gmail.com>
PR target/42891 PR target/42891
......
...@@ -1510,97 +1510,106 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, ...@@ -1510,97 +1510,106 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node,
/* Never inline regular functions into always-inline functions /* Never inline regular functions into always-inline functions
during incremental inlining. */ during incremental inlining. */
&& !node->local.disregard_inline_limits) && !node->local.disregard_inline_limits)
for (e = node->callees; e; e = e->next_callee) {
{ bitmap visited = BITMAP_ALLOC (NULL);
int allowed_growth = 0; for (e = node->callees; e; e = e->next_callee)
if (!e->callee->local.inlinable {
|| !e->inline_failed int allowed_growth = 0;
|| e->callee->local.disregard_inline_limits) if (!e->callee->local.inlinable
continue; || !e->inline_failed
if (dump_file) || e->callee->local.disregard_inline_limits)
fprintf (dump_file, "Considering inline candidate %s.\n",
cgraph_node_name (e->callee));
if (cgraph_recursive_inlining_p (node, e->callee, &e->inline_failed))
{
if (dump_file)
{
indent_to (dump_file, depth);
fprintf (dump_file, "Not inlining: recursive call.\n");
}
continue; continue;
} /* We are inlining a function to all call-sites in node
if (gimple_in_ssa_p (DECL_STRUCT_FUNCTION (node->decl)) or to none. So visit each candidate only once. */
!= gimple_in_ssa_p (DECL_STRUCT_FUNCTION (e->callee->decl))) if (!bitmap_set_bit (visited, e->callee->uid))
{
if (dump_file)
{
indent_to (dump_file, depth);
fprintf (dump_file, "Not inlining: SSA form does not match.\n");
}
continue; continue;
} if (dump_file)
fprintf (dump_file, "Considering inline candidate %s.\n",
if (cgraph_maybe_hot_edge_p (e) && leaf_node_p (e->callee) cgraph_node_name (e->callee));
&& optimize_function_for_speed_p (cfun)) if (cgraph_recursive_inlining_p (node, e->callee, &e->inline_failed))
allowed_growth = PARAM_VALUE (PARAM_EARLY_INLINING_INSNS); {
if (dump_file)
{
indent_to (dump_file, depth);
fprintf (dump_file, "Not inlining: recursive call.\n");
}
continue;
}
if (gimple_in_ssa_p (DECL_STRUCT_FUNCTION (node->decl))
!= gimple_in_ssa_p (DECL_STRUCT_FUNCTION (e->callee->decl)))
{
if (dump_file)
{
indent_to (dump_file, depth);
fprintf (dump_file,
"Not inlining: SSA form does not match.\n");
}
continue;
}
/* When the function body would grow and inlining the function won't if (cgraph_maybe_hot_edge_p (e) && leaf_node_p (e->callee)
eliminate the need for offline copy of the function, don't inline. && optimize_function_for_speed_p (cfun))
*/ allowed_growth = PARAM_VALUE (PARAM_EARLY_INLINING_INSNS);
if (((mode == INLINE_SIZE || mode == INLINE_SIZE_NORECURSIVE)
|| (!flag_inline_functions /* When the function body would grow and inlining the function
&& !DECL_DECLARED_INLINE_P (e->callee->decl))) won't eliminate the need for offline copy of the function,
&& (cgraph_estimate_size_after_inlining (1, e->caller, e->callee) don't inline. */
> e->caller->global.size + allowed_growth) if (((mode == INLINE_SIZE || mode == INLINE_SIZE_NORECURSIVE)
&& cgraph_estimate_growth (e->callee) > allowed_growth) || (!flag_inline_functions
{ && !DECL_DECLARED_INLINE_P (e->callee->decl)))
if (dump_file) && (cgraph_estimate_size_after_inlining (1, e->caller, e->callee)
{ > e->caller->global.size + allowed_growth)
indent_to (dump_file, depth); && cgraph_estimate_growth (e->callee) > allowed_growth)
fprintf (dump_file, {
"Not inlining: code size would grow by %i.\n", if (dump_file)
cgraph_estimate_size_after_inlining (1, e->caller, {
e->callee) indent_to (dump_file, depth);
- e->caller->global.size); fprintf (dump_file,
} "Not inlining: code size would grow by %i.\n",
continue; cgraph_estimate_size_after_inlining (1, e->caller,
} e->callee)
if (!cgraph_check_inline_limits (node, e->callee, &e->inline_failed, - e->caller->global.size);
false) }
|| e->call_stmt_cannot_inline_p) continue;
{ }
if (dump_file) if (!cgraph_check_inline_limits (node, e->callee, &e->inline_failed,
{ false)
indent_to (dump_file, depth); || e->call_stmt_cannot_inline_p)
fprintf (dump_file, "Not inlining: %s.\n", {
cgraph_inline_failed_string (e->inline_failed)); if (dump_file)
} {
continue; indent_to (dump_file, depth);
} fprintf (dump_file, "Not inlining: %s.\n",
if (!e->callee->analyzed) cgraph_inline_failed_string (e->inline_failed));
{ }
if (dump_file) continue;
{ }
indent_to (dump_file, depth); if (!e->callee->analyzed)
fprintf (dump_file, {
"Not inlining: Function body no longer available.\n"); if (dump_file)
} {
continue; indent_to (dump_file, depth);
} fprintf (dump_file,
if (!tree_can_inline_p (e)) "Not inlining: Function body no longer available.\n");
{ }
if (dump_file) continue;
{ }
indent_to (dump_file, depth); if (!tree_can_inline_p (e))
fprintf (dump_file, {
"Not inlining: %s.", if (dump_file)
cgraph_inline_failed_string (e->inline_failed)); {
} indent_to (dump_file, depth);
continue; fprintf (dump_file,
} "Not inlining: %s.",
if (cgraph_default_inline_p (e->callee, &failed_reason)) cgraph_inline_failed_string (e->inline_failed));
inlined |= try_inline (e, mode, depth); }
} continue;
}
if (cgraph_default_inline_p (e->callee, &failed_reason))
inlined |= try_inline (e, mode, depth);
}
BITMAP_FREE (visited);
}
node->aux = (void *)(size_t) old_mode; node->aux = (void *)(size_t) old_mode;
return inlined; return inlined;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment