aboutsummaryrefslogtreecommitdiff
path: root/gcc/ipa-inline-analysis.c
diff options
context:
space:
mode:
authorJan Hubicka <jh@suse.cz>2011-06-10 13:43:01 +0200
committerJan Hubicka <hubicka@gcc.gnu.org>2011-06-10 11:43:01 +0000
commita5b1779f81ebfa6d13f0e5116234c8282d71c46d (patch)
tree1d26feeab584ee3df009ef00a986f63acea4c6bd /gcc/ipa-inline-analysis.c
parentc1ae3ca5d8842831d35b08e6e9ae1f983b39bc6b (diff)
downloadgcc-a5b1779f81ebfa6d13f0e5116234c8282d71c46d.zip
gcc-a5b1779f81ebfa6d13f0e5116234c8282d71c46d.tar.gz
gcc-a5b1779f81ebfa6d13f0e5116234c8282d71c46d.tar.bz2
ipa-inline-transform.c (can_remove_node_now_p): Move out of...
* ipa-inline-transform.c (can_remove_node_now_p): Move out of... (clone_inlined_nodes): ... here. (inline_call): Use cgraph_function_or_thunk_node; redirect edge to real destination prior inlining. * ipa-inline.c (caller_growth_limits, can_inline_edge_p, can_early_inline_edge_p, want_early_inline_function_p, want_early_inline_function_p, want_inline_small_function_p, want_inline_self_recursive_call_p, want_inline_function_called_once_p, edge_badness, update_all_callee_keys, lookup_recursive_calls, add_new_edges_to_heap, inline_small_functions, flatten_function, inline_always_inline_functions, early_inline_small_functions): Use cgraph_function_or_thunk_node. * ipa-inline-analysis.c (evaluate_conditions_for_edge, dump_inline_edge_summary, estimate_function_body_sizes): Likewise. (do_estimate_edge_growth_1): Break out from ... (do_estimate_growth) ... here; walk aliases. (inline_generate_summary): Skip aliases. From-SVN: r174901
Diffstat (limited to 'gcc/ipa-inline-analysis.c')
-rw-r--r--gcc/ipa-inline-analysis.c88
1 files changed, 57 insertions, 31 deletions
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c
index ad93544..473f554 100644
--- a/gcc/ipa-inline-analysis.c
+++ b/gcc/ipa-inline-analysis.c
@@ -589,7 +589,8 @@ static clause_t
evaluate_conditions_for_edge (struct cgraph_edge *e, bool inline_p)
{
clause_t clause = inline_p ? 0 : 1 << predicate_not_inlined_condition;
- struct inline_summary *info = inline_summary (e->callee);
+ struct cgraph_node *callee = cgraph_function_or_thunk_node (e->callee, NULL);
+ struct inline_summary *info = inline_summary (callee);
int i;
if (ipa_node_params_vector && info->conds
@@ -615,7 +616,7 @@ evaluate_conditions_for_edge (struct cgraph_edge *e, bool inline_p)
if (cst)
VEC_replace (tree, known_vals, i, cst);
}
- clause = evaluate_conditions_for_known_args (e->callee,
+ clause = evaluate_conditions_for_known_args (callee,
inline_p, known_vals);
VEC_free (tree, heap, known_vals);
}
@@ -919,9 +920,10 @@ dump_inline_edge_summary (FILE * f, int indent, struct cgraph_node *node,
for (edge = node->callees; edge; edge = edge->next_callee)
{
struct inline_edge_summary *es = inline_edge_summary (edge);
+ struct cgraph_node *callee = cgraph_function_or_thunk_node (edge->callee, NULL);
fprintf (f, "%*s%s/%i %s\n%*s loop depth:%2i freq:%4i size:%2i time: %2i callee size:%2i stack:%2i",
- indent, "", cgraph_node_name (edge->callee),
- edge->callee->uid,
+ indent, "", cgraph_node_name (callee),
+ callee->uid,
!edge->inline_failed ? "inlined"
: cgraph_inline_failed_string (edge->inline_failed),
indent, "",
@@ -929,8 +931,8 @@ dump_inline_edge_summary (FILE * f, int indent, struct cgraph_node *node,
edge->frequency,
es->call_stmt_size,
es->call_stmt_time,
- (int)inline_summary (edge->callee)->size,
- (int)inline_summary (edge->callee)->estimated_stack_size);
+ (int)inline_summary (callee)->size,
+ (int)inline_summary (callee)->estimated_stack_size);
if (es->predicate)
{
fprintf (f, " predicate: ");
@@ -942,10 +944,10 @@ dump_inline_edge_summary (FILE * f, int indent, struct cgraph_node *node,
{
fprintf (f, "%*sStack frame offset %i, callee self size %i, callee size %i\n",
indent+2, "",
- (int)inline_summary (edge->callee)->stack_frame_offset,
- (int)inline_summary (edge->callee)->estimated_self_stack_size,
- (int)inline_summary (edge->callee)->estimated_stack_size);
- dump_inline_edge_summary (f, indent+2, edge->callee, info);
+ (int)inline_summary (callee)->stack_frame_offset,
+ (int)inline_summary (callee)->estimated_self_stack_size,
+ (int)inline_summary (callee)->estimated_stack_size);
+ dump_inline_edge_summary (f, indent+2, callee, info);
}
}
for (edge = node->indirect_calls; edge; edge = edge->next_callee)
@@ -1525,7 +1527,10 @@ estimate_function_body_sizes (struct cgraph_node *node, bool early)
/* Do not inline calls where we cannot triviall work around
mismatches in argument or return types. */
if (edge->callee
- && !gimple_check_call_matching_types (stmt, edge->callee->decl))
+ && cgraph_function_or_thunk_node (edge->callee, NULL)
+ && !gimple_check_call_matching_types (stmt,
+ cgraph_function_or_thunk_node (edge->callee,
+ NULL)->decl))
{
edge->call_stmt_cannot_inline_p = true;
gimple_call_set_cannot_inline (stmt, true);
@@ -2110,6 +2115,7 @@ int
do_estimate_edge_growth (struct cgraph_edge *edge)
{
int size;
+ struct cgraph_node *callee;
/* When we do caching, use do_estimate_edge_time to populate the entry. */
@@ -2122,10 +2128,11 @@ do_estimate_edge_growth (struct cgraph_edge *edge)
gcc_checking_assert (size);
return size - (size > 0);
}
+ callee = cgraph_function_or_thunk_node (edge->callee, NULL);
/* Early inliner runs without caching, go ahead and do the dirty work. */
gcc_checking_assert (edge->inline_failed);
- estimate_node_size_and_time (edge->callee,
+ estimate_node_size_and_time (callee,
evaluate_conditions_for_edge (edge, true),
&size, NULL);
gcc_checking_assert (inline_edge_summary (edge)->call_stmt_size);
@@ -2171,15 +2178,20 @@ estimate_size_after_inlining (struct cgraph_node *node,
}
-/* Estimate the growth caused by inlining NODE into all callees. */
+struct growth_data
+{
+ bool self_recursive;
+ int growth;
+};
-int
-do_estimate_growth (struct cgraph_node *node)
+
+/* Worker for do_estimate_growth. Collect growth for all callers. */
+
+static bool
+do_estimate_growth_1 (struct cgraph_node *node, void *data)
{
- int growth = 0;
struct cgraph_edge *e;
- bool self_recursive = false;
- struct inline_summary *info = inline_summary (node);
+ struct growth_data *d = (struct growth_data *) data;
for (e = node->callers; e; e = e->next_caller)
{
@@ -2188,37 +2200,50 @@ do_estimate_growth (struct cgraph_node *node)
if (e->caller == node
|| (e->caller->global.inlined_to
&& e->caller->global.inlined_to == node))
- self_recursive = true;
- growth += estimate_edge_growth (e);
+ d->self_recursive = true;
+ d->growth += estimate_edge_growth (e);
}
-
+ return false;
+}
+
+
+/* Estimate the growth caused by inlining NODE into all callees. */
+
+int
+do_estimate_growth (struct cgraph_node *node)
+{
+ struct growth_data d = {0, false};
+ struct inline_summary *info = inline_summary (node);
+
+ cgraph_for_node_and_aliases (node, do_estimate_growth_1, &d, true);
/* For self recursive functions the growth estimation really should be
infinity. We don't want to return very large values because the growth
plays various roles in badness computation fractions. Be sure to not
return zero or negative growths. */
- if (self_recursive)
- growth = growth < info->size ? info->size : growth;
+ if (d.self_recursive)
+ d.growth = d.growth < info->size ? info->size : d.growth;
else
{
- if (cgraph_will_be_removed_from_program_if_no_direct_calls (node)
- && !DECL_EXTERNAL (node->decl))
- growth -= info->size;
+ if (!DECL_EXTERNAL (node->decl)
+ && !cgraph_will_be_removed_from_program_if_no_direct_calls (node))
+ d.growth -= info->size;
/* COMDAT functions are very often not shared across multiple units since they
- come from various template instantiations. Take this into account. */
+ come from various template instantiations. Take this into account.
+ FIXME: allow also COMDATs with COMDAT aliases. */
else if (DECL_COMDAT (node->decl)
&& cgraph_can_remove_if_no_direct_calls_p (node))
- growth -= (info->size
- * (100 - PARAM_VALUE (PARAM_COMDAT_SHARING_PROBABILITY)) + 50) / 100;
+ d.growth -= (info->size
+ * (100 - PARAM_VALUE (PARAM_COMDAT_SHARING_PROBABILITY)) + 50) / 100;
}
if (node_growth_cache)
{
if ((int)VEC_length (int, node_growth_cache) <= node->uid)
VEC_safe_grow_cleared (int, heap, node_growth_cache, cgraph_max_uid);
- VEC_replace (int, node_growth_cache, node->uid, growth + (growth >= 0));
+ VEC_replace (int, node_growth_cache, node->uid, d.growth + (d.growth >= 0));
}
- return growth;
+ return d.growth;
}
@@ -2282,6 +2307,7 @@ inline_generate_summary (void)
ipa_register_cgraph_hooks ();
FOR_EACH_DEFINED_FUNCTION (node)
+ if (!node->alias)
inline_analyze_function (node);
}