Commit 9de21a23 by Josh Conner Committed by Josh Conner

ipa-inline.c (cgraph_edge_badness): Update comments.

        * ipa-inline.c (cgraph_edge_badness): Update comments.  Invert shift
        direction of badness if negative.
        (cgraph_default_inline_p): Add reason to parameters, and assign it
        a value.
        (cgraph_decide_inlining_of_small_functions): New parameter in call
        to cgraph_default_inline_p.
        (cgraph_decide_inlining_incrementally): Likewise.
        * cgraphunit.c (decide_is_function_needed): Likewise.
        * cgraph.h (cgraph_default_inline_p): Likewise.

From-SVN: r102497
parent 206048bd
2005-07-28 Josh Conner <jconner@apple.com>
* ipa-inline.c (cgraph_edge_badness): Update comments. Invert shift
direction of badness if negative.
(cgraph_default_inline_p): Add reason to parameters, and assign it
a value.
(cgraph_decide_inlining_of_small_functions): New parameter in call
to cgraph_default_inline_p.
(cgraph_decide_inlining_incrementally): Likewise.
* cgraphunit.c (decide_is_function_needed): Likewise.
* cgraph.h (cgraph_default_inline_p): Likewise.
2005-07-28 Volker Reichelt <reichelt@igpm.rwth-aachen.de> 2005-07-28 Volker Reichelt <reichelt@igpm.rwth-aachen.de>
* builtins.c: Fix comment typo(s). * builtins.c: Fix comment typo(s).
......
...@@ -287,5 +287,5 @@ int cgraph_postorder (struct cgraph_node **); ...@@ -287,5 +287,5 @@ int cgraph_postorder (struct cgraph_node **);
bool cgraph_decide_inlining_incrementally (struct cgraph_node *, bool); bool cgraph_decide_inlining_incrementally (struct cgraph_node *, bool);
void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool); void cgraph_clone_inlined_nodes (struct cgraph_edge *, bool);
void cgraph_mark_inline_edge (struct cgraph_edge *); void cgraph_mark_inline_edge (struct cgraph_edge *);
bool cgraph_default_inline_p (struct cgraph_node *); bool cgraph_default_inline_p (struct cgraph_node *, const char **);
#endif /* GCC_CGRAPH_H */ #endif /* GCC_CGRAPH_H */
...@@ -248,7 +248,7 @@ decide_is_function_needed (struct cgraph_node *node, tree decl) ...@@ -248,7 +248,7 @@ decide_is_function_needed (struct cgraph_node *node, tree decl)
/* When declared inline, defer even the uninlinable functions. /* When declared inline, defer even the uninlinable functions.
This allows them to be eliminated when unused. */ This allows them to be eliminated when unused. */
&& !DECL_DECLARED_INLINE_P (decl) && !DECL_DECLARED_INLINE_P (decl)
&& (!node->local.inlinable || !cgraph_default_inline_p (node)))) && (!node->local.inlinable || !cgraph_default_inline_p (node, NULL))))
return true; return true;
return false; return false;
......
...@@ -277,14 +277,42 @@ cgraph_check_inline_limits (struct cgraph_node *to, struct cgraph_node *what, ...@@ -277,14 +277,42 @@ cgraph_check_inline_limits (struct cgraph_node *to, struct cgraph_node *what,
/* Return true when function N is small enough to be inlined. */ /* Return true when function N is small enough to be inlined. */
bool bool
cgraph_default_inline_p (struct cgraph_node *n) cgraph_default_inline_p (struct cgraph_node *n, const char **reason)
{ {
if (!DECL_INLINE (n->decl) || !DECL_SAVED_TREE (n->decl)) if (!DECL_INLINE (n->decl))
return false; {
if (reason)
*reason = N_("function not inlinable");
return false;
}
if (!DECL_SAVED_TREE (n->decl))
{
if (reason)
*reason = N_("function body not available");
return false;
}
if (DECL_DECLARED_INLINE_P (n->decl)) if (DECL_DECLARED_INLINE_P (n->decl))
return n->global.insns < MAX_INLINE_INSNS_SINGLE; {
if (n->global.insns >= MAX_INLINE_INSNS_SINGLE)
{
if (reason)
*reason = N_("--param max-inline-insns-single limit reached");
return false;
}
}
else else
return n->global.insns < MAX_INLINE_INSNS_AUTO; {
if (n->global.insns >= MAX_INLINE_INSNS_AUTO)
{
if (reason)
*reason = N_("--param max-inline-insns-auto limit reached");
return false;
}
}
return true;
} }
/* Return true when inlining WHAT would create recursive inlining. /* Return true when inlining WHAT would create recursive inlining.
...@@ -326,15 +354,9 @@ cgraph_maybe_hot_edge_p (struct cgraph_edge *edge) ...@@ -326,15 +354,9 @@ cgraph_maybe_hot_edge_p (struct cgraph_edge *edge)
metrics may accurately depend on values such as number of inlinable callers metrics may accurately depend on values such as number of inlinable callers
of the function or function body size. of the function or function body size.
For the moment we use estimated growth caused by inlining callee into all
it's callers for driving the inlining but once we have loop depth or
frequency information readily available we should do better.
With profiling we use number of executions of each edge to drive the cost. With profiling we use number of executions of each edge to drive the cost.
We also should distinguish hot and cold calls where the cold calls are We also should distinguish hot and cold calls where the cold calls are
inlined into only when code size is overall improved. inlined into only when code size is overall improved.
Value INT_MAX can be returned to prevent function from being inlined.
*/ */
static int static int
...@@ -355,8 +377,12 @@ cgraph_edge_badness (struct cgraph_edge *edge) ...@@ -355,8 +377,12 @@ cgraph_edge_badness (struct cgraph_edge *edge)
{ {
int nest = MIN (edge->loop_nest, 8); int nest = MIN (edge->loop_nest, 8);
int badness = cgraph_estimate_growth (edge->callee) * 256; int badness = cgraph_estimate_growth (edge->callee) * 256;
badness >>= nest; /* Decrease badness if call is nested. */
if (badness > 0)
badness >>= nest;
else
badness <<= nest;
/* Make recursive inlining happen always after other inlining is done. */ /* Make recursive inlining happen always after other inlining is done. */
if (cgraph_recursive_inlining_p (edge->caller, edge->callee, NULL)) if (cgraph_recursive_inlining_p (edge->caller, edge->callee, NULL))
...@@ -609,6 +635,7 @@ cgraph_decide_inlining_of_small_functions (void) ...@@ -609,6 +635,7 @@ cgraph_decide_inlining_of_small_functions (void)
{ {
struct cgraph_node *node; struct cgraph_node *node;
struct cgraph_edge *edge; struct cgraph_edge *edge;
const char *failed_reason;
fibheap_t heap = fibheap_new (); fibheap_t heap = fibheap_new ();
bitmap updated_nodes = BITMAP_ALLOC (NULL); bitmap updated_nodes = BITMAP_ALLOC (NULL);
...@@ -626,10 +653,9 @@ cgraph_decide_inlining_of_small_functions (void) ...@@ -626,10 +653,9 @@ cgraph_decide_inlining_of_small_functions (void)
fprintf (dump_file, "Considering inline candidate %s.\n", cgraph_node_name (node)); fprintf (dump_file, "Considering inline candidate %s.\n", cgraph_node_name (node));
node->global.estimated_growth = INT_MIN; node->global.estimated_growth = INT_MIN;
if (!cgraph_default_inline_p (node)) if (!cgraph_default_inline_p (node, &failed_reason))
{ {
cgraph_set_inline_failed (node, cgraph_set_inline_failed (node, failed_reason);
N_("--param max-inline-insns-single limit reached"));
continue; continue;
} }
...@@ -708,13 +734,11 @@ cgraph_decide_inlining_of_small_functions (void) ...@@ -708,13 +734,11 @@ cgraph_decide_inlining_of_small_functions (void)
} }
continue; continue;
} }
if (!cgraph_default_inline_p (edge->callee)) if (!cgraph_default_inline_p (edge->callee, &edge->inline_failed))
{ {
if (!cgraph_recursive_inlining_p (edge->caller, edge->callee, if (!cgraph_recursive_inlining_p (edge->caller, edge->callee,
&edge->inline_failed)) &edge->inline_failed))
{ {
edge->inline_failed =
N_("--param max-inline-insns-single limit reached after inlining into the callee");
if (dump_file) if (dump_file)
fprintf (dump_file, " inline_failed:%s.\n", edge->inline_failed); fprintf (dump_file, " inline_failed:%s.\n", edge->inline_failed);
} }
...@@ -954,6 +978,7 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early) ...@@ -954,6 +978,7 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early)
{ {
struct cgraph_edge *e; struct cgraph_edge *e;
bool inlined = false; bool inlined = false;
const char *failed_reason;
/* First of all look for always inline functions. */ /* First of all look for always inline functions. */
for (e = node->callees; e; e = e->next_callee) for (e = node->callees; e; e = e->next_callee)
...@@ -984,7 +1009,7 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early) ...@@ -984,7 +1009,7 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early)
&& cgraph_check_inline_limits (node, e->callee, &e->inline_failed) && cgraph_check_inline_limits (node, e->callee, &e->inline_failed)
&& DECL_SAVED_TREE (e->callee->decl)) && DECL_SAVED_TREE (e->callee->decl))
{ {
if (cgraph_default_inline_p (e->callee)) if (cgraph_default_inline_p (e->callee, &failed_reason))
{ {
if (dump_file && early) if (dump_file && early)
fprintf (dump_file, " Early inlining %s into %s\n", fprintf (dump_file, " Early inlining %s into %s\n",
...@@ -993,8 +1018,7 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early) ...@@ -993,8 +1018,7 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early)
inlined = true; inlined = true;
} }
else if (!early) else if (!early)
e->inline_failed e->inline_failed = failed_reason;
= N_("--param max-inline-insns-single limit reached");
} }
if (early && inlined) if (early && 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