int newsize;
int limit;
- if (to->global.inlined_to)
- to = to->global.inlined_to;
-
for (e = to->callees; e; e = e->next_callee)
if (e->callee == what)
times++;
+ if (to->global.inlined_to)
+ to = to->global.inlined_to;
+
/* When inlining large function body called once into small function,
take the inlined function as base for limiting the growth. */
if (to->local.self_insns > what->local.self_insns)
limit += limit * PARAM_VALUE (PARAM_LARGE_FUNCTION_GROWTH) / 100;
+ /* Check the size after inlining against the function limits. But allow
+ the function to shrink if it went over the limits by forced inlining. */
newsize = cgraph_estimate_size_after_inlining (times, to, what);
- if (newsize > PARAM_VALUE (PARAM_LARGE_FUNCTION_INSNS)
+ if (newsize >= to->global.insns
+ && newsize > PARAM_VALUE (PARAM_LARGE_FUNCTION_INSNS)
&& newsize > limit)
{
if (reason)
&& !e->callee->local.disregard_inline_limits
&& !cgraph_recursive_inlining_p (node, e->callee, &e->inline_failed)
&& (!early
- || (cgraph_estimate_size_after_inlining (1, e->caller, node)
+ || (cgraph_estimate_size_after_inlining (1, e->caller, e->callee)
<= e->caller->global.insns))
&& cgraph_check_inline_limits (node, e->callee, &e->inline_failed)
&& (DECL_SAVED_TREE (e->callee->decl) || e->callee->inline_decl))
if (node->analyzed && node->local.inlinable
&& (node->needed || node->reachable)
&& node->callers)
- cgraph_decide_inlining_incrementally (node, true);
+ {
+ if (cgraph_decide_inlining_incrementally (node, true))
+ ggc_collect ();
+ }
}
cgraph_remove_unreachable_nodes (true, dump_file);
#ifdef ENABLE_CHECKING