summaryrefslogtreecommitdiff
path: root/gcc/cgraph.c
diff options
context:
space:
mode:
authorhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-13 09:19:09 +0000
committerhubicka <hubicka@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-13 09:19:09 +0000
commit794fd2828d1d8123cdf93c2b20535a28c40f79e8 (patch)
tree7e356df77924fcdd550af73036e37d71e9ab5ddb /gcc/cgraph.c
parent11371434aec7740fe75286e50be7f5cea91ae5c1 (diff)
downloadgcc-794fd2828d1d8123cdf93c2b20535a28c40f79e8.tar.gz
* cgraph.c (cgraph_for_node_thunks_and_aliases,
cgraph_for_node_and_aliases): Fix thinko in recursive walking. (nonremovable_p): New function. (cgraph_can_remove_if_no_direct_calls_p): New function. (used_from_object_file_p): New functoin. (cgraph_will_be_removed_from_program_if_no_direct_calls): Look for references from aliases. * cgraph.h (cgraph_can_remove_if_no_direct_calls_p): Bring offline. * ipa-inline.c (check_caller_edge): New function. (want_inline_function_called_once_p): Use it; accept aliases called once, too. * ipa-inline-analysis.c (do_estimate_growth): Remove FIXME. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@174985 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/cgraph.c')
-rw-r--r--gcc/cgraph.c44
1 files changed, 40 insertions, 4 deletions
diff --git a/gcc/cgraph.c b/gcc/cgraph.c
index 2805d46dfad..dfa5439ad96 100644
--- a/gcc/cgraph.c
+++ b/gcc/cgraph.c
@@ -2567,14 +2567,18 @@ cgraph_for_node_thunks_and_aliases (struct cgraph_node *node,
if (e->caller->thunk.thunk_p
&& (include_overwritable
|| cgraph_function_body_availability (e->caller)))
- cgraph_for_node_thunks_and_aliases (e->caller, callback, data, include_overwritable);
+ if (cgraph_for_node_thunks_and_aliases (e->caller, callback, data,
+ include_overwritable))
+ return true;
for (i = 0; ipa_ref_list_refering_iterate (&node->ref_list, i, ref); i++)
if (ref->use == IPA_REF_ALIAS)
{
struct cgraph_node *alias = ipa_ref_refering_node (ref);
if (include_overwritable
|| cgraph_function_body_availability (alias) > AVAIL_OVERWRITABLE)
- cgraph_for_node_thunks_and_aliases (alias, callback, data, include_overwritable);
+ if (cgraph_for_node_thunks_and_aliases (alias, callback, data,
+ include_overwritable))
+ return true;
}
return false;
}
@@ -2600,7 +2604,9 @@ cgraph_for_node_and_aliases (struct cgraph_node *node,
struct cgraph_node *alias = ipa_ref_refering_node (ref);
if (include_overwritable
|| cgraph_function_body_availability (alias) > AVAIL_OVERWRITABLE)
- cgraph_for_node_and_aliases (alias, callback, data, include_overwritable);
+ if (cgraph_for_node_and_aliases (alias, callback, data,
+ include_overwritable))
+ return true;
}
return false;
}
@@ -2900,6 +2906,36 @@ cgraph_can_remove_if_no_direct_calls_and_refs_p (struct cgraph_node *node)
return true;
}
+/* Worker for cgraph_can_remove_if_no_direct_calls_p. */
+
+static bool
+nonremovable_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
+{
+ return !cgraph_can_remove_if_no_direct_calls_and_refs_p (node);
+}
+
+/* Return true when function NODE and its aliases can be removed from callgraph
+ if all direct calls are eliminated. */
+
+bool
+cgraph_can_remove_if_no_direct_calls_p (struct cgraph_node *node)
+{
+ /* Extern inlines can always go, we will use the external definition. */
+ if (DECL_EXTERNAL (node->decl))
+ return true;
+ if (node->address_taken)
+ return false;
+ return !cgraph_for_node_and_aliases (node, nonremovable_p, NULL, true);
+}
+
+/* Worker for cgraph_can_remove_if_no_direct_calls_p. */
+
+static bool
+used_from_object_file_p (struct cgraph_node *node, void *data ATTRIBUTE_UNUSED)
+{
+ return cgraph_used_from_object_file_p (node);
+}
+
/* Return true when function NODE can be expected to be removed
from program when direct calls in this compilation unit are removed.
@@ -2918,7 +2954,7 @@ bool
cgraph_will_be_removed_from_program_if_no_direct_calls (struct cgraph_node *node)
{
gcc_assert (!node->global.inlined_to);
- if (cgraph_used_from_object_file_p (node))
+ if (cgraph_for_node_and_aliases (node, used_from_object_file_p, NULL, true))
return false;
if (!in_lto_p && !flag_whole_program)
return cgraph_only_called_directly_p (node);