summaryrefslogtreecommitdiff
path: root/gcc/ipa-inline.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-19 17:20:20 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2007-01-19 17:20:20 +0000
commita223d5edd4480033c6aab02e223c9841b7a8efa3 (patch)
treeba66283e85dda5a10fa85973c05e74195f8b2c4b /gcc/ipa-inline.c
parentbf6fb4510b8c9474e7b85eb5342dd715bbb1c9b7 (diff)
downloadgcc-a223d5edd4480033c6aab02e223c9841b7a8efa3.tar.gz
* ipa-inline.c (cgraph_decide_inlining_incrementally): Instead of 'early' argument
take inlining mode argument specifying whether to inline for size/speeed or all functions; add support for flattening; improve dumpting. (cgraph_early_inlining): Update call of decide_inlining_incrementally. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@120970 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ipa-inline.c')
-rw-r--r--gcc/ipa-inline.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c
index d369a32dc8e..d1983d949e9 100644
--- a/gcc/ipa-inline.c
+++ b/gcc/ipa-inline.c
@@ -1136,11 +1136,17 @@ cgraph_decide_inlining (void)
return 0;
}
+enum inlining_mode {
+ INLINE_SIZE,
+ INLINE_SPEED,
+ INLINE_ALL
+};
+
/* Decide on the inlining. We do so in the topological order to avoid
expenses on updating data structures. */
static unsigned int
-cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early)
+cgraph_decide_inlining_incrementally (struct cgraph_node *node, enum inlining_mode mode)
{
struct cgraph_edge *e;
bool inlined = false;
@@ -1150,10 +1156,17 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early)
#ifdef ENABLE_CHECKING
verify_cgraph_node (node);
#endif
+ if (lookup_attribute ("flatten", DECL_ATTRIBUTES (node->decl)) != NULL)
+ {
+ if (dump_file)
+ fprintf (dump_file, " Flattening %s\n", cgraph_node_name (node));
+ mode = INLINE_ALL;
+ }
/* First of all look for always inline functions. */
for (e = node->callees; e; e = e->next_callee)
- if (e->callee->local.disregard_inline_limits
+ if ((e->callee->local.disregard_inline_limits
+ || (mode == INLINE_ALL && e->callee->local.inlinable))
&& e->inline_failed
&& (gimple_in_ssa_p (DECL_STRUCT_FUNCTION (node->decl))
== gimple_in_ssa_p (DECL_STRUCT_FUNCTION (e->callee->decl)))
@@ -1162,25 +1175,27 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early)
in duplicate_decls. See gcc.c-torture/compile/20011119-2.c */
&& (DECL_SAVED_TREE (e->callee->decl) || e->callee->inline_decl))
{
- if (dump_file && early)
+ if (dump_file)
{
- fprintf (dump_file, " Early inlining %s",
+ fprintf (dump_file, " Inlining always_inline %s",
cgraph_node_name (e->callee));
fprintf (dump_file, " into %s\n", cgraph_node_name (node));
}
cgraph_mark_inline (e);
- /* In order to fully inline alway_inline functions at -O0, we need to
+ /* In order to fully inline always_inline functions at -O0, we need to
recurse here, since the inlined functions might not be processed by
- incremental inlining at all yet. */
+ incremental inlining at all yet.
+
+ Also flattening needs to be done recursively. */
- if (!flag_unit_at_a_time)
- cgraph_decide_inlining_incrementally (e->callee, early);
+ if (!flag_unit_at_a_time || mode == INLINE_ALL)
+ cgraph_decide_inlining_incrementally (e->callee, mode);
inlined = true;
}
/* Now do the automatic inlining. */
- if (!flag_really_no_inline)
+ if (!flag_really_no_inline && mode != INLINE_ALL)
for (e = node->callees; e; e = e->next_callee)
if (e->callee->local.inlinable
&& e->inline_failed
@@ -1188,28 +1203,30 @@ cgraph_decide_inlining_incrementally (struct cgraph_node *node, bool early)
&& !cgraph_recursive_inlining_p (node, e->callee, &e->inline_failed)
&& (gimple_in_ssa_p (DECL_STRUCT_FUNCTION (node->decl))
== gimple_in_ssa_p (DECL_STRUCT_FUNCTION (e->callee->decl)))
- && (!early
+ && (mode != INLINE_SIZE
|| (cgraph_estimate_size_after_inlining (1, e->caller, e->callee)
<= e->caller->global.insns))
&& cgraph_check_inline_limits (node, e->callee, &e->inline_failed,
- false)
+ false)
&& (DECL_SAVED_TREE (e->callee->decl) || e->callee->inline_decl))
{
if (cgraph_default_inline_p (e->callee, &failed_reason))
{
- if (dump_file && early)
+ if (dump_file)
{
- fprintf (dump_file, " Early inlining %s",
+ fprintf (dump_file, " Inlining %s",
cgraph_node_name (e->callee));
fprintf (dump_file, " into %s\n", cgraph_node_name (node));
}
cgraph_mark_inline (e);
inlined = true;
+ if (!flag_unit_at_a_time)
+ cgraph_decide_inlining_incrementally (e->callee, mode);
}
- else if (!early)
+ else if (!flag_unit_at_a_time)
e->inline_failed = failed_reason;
}
- if (early && inlined && !node->global.inlined_to)
+ if (flag_unit_at_a_time && inlined && !node->global.inlined_to)
{
timevar_push (TV_INTEGRATION);
todo = optimize_inline_calls (current_function_decl);
@@ -1259,7 +1276,9 @@ cgraph_early_inlining (void)
if (sorrycount || errorcount)
return 0;
- return cgraph_decide_inlining_incrementally (node, flag_unit_at_a_time);
+ return cgraph_decide_inlining_incrementally (node,
+ flag_unit_at_a_time
+ ? INLINE_SIZE : INLINE_SPEED);
}
/* When inlining shall be performed. */