diff options
Diffstat (limited to 'gcc/ipa-inline-analysis.c')
-rw-r--r-- | gcc/ipa-inline-analysis.c | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index d7471630617..5707f6c9603 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -3978,6 +3978,9 @@ check_callers (cgraph_node *node, int *max_callers) { ipa_ref *ref; + if (!node->can_remove_if_no_direct_calls_and_refs_p ()) + return true; + for (cgraph_edge *e = node->callers; e; e = e->next_caller) { (*max_callers)--; @@ -4007,23 +4010,13 @@ growth_likely_positive (struct cgraph_node *node, struct cgraph_edge *e; gcc_checking_assert (edge_growth > 0); + /* First quickly check if NODE is removable at all. */ if (DECL_EXTERNAL (node->decl)) return true; - /* Unlike for functions called once, we play unsafe with - COMDATs. We can allow that since we know functions - in consideration are small (and thus risk is small) and - moreover grow estimates already accounts that COMDAT - functions may or may not disappear when eliminated from - current unit. With good probability making aggressive - choice in all units is going to make overall program - smaller. */ - if (DECL_COMDAT (node->decl)) - { - if (!node->can_remove_if_no_direct_calls_p ()) - return true; - } - else if (!node->will_be_removed_from_program_if_no_direct_calls_p ()) + if (!node->can_remove_if_no_direct_calls_and_refs_p () + || node->address_taken) return true; + max_callers = inline_summaries->get (node)->size * 4 / edge_growth + 2; for (e = node->callers; e; e = e->next_caller) @@ -4039,6 +4032,22 @@ growth_likely_positive (struct cgraph_node *node, if (check_callers (dyn_cast <cgraph_node *> (ref->referring), &max_callers)) return true; + /* Unlike for functions called once, we play unsafe with + COMDATs. We can allow that since we know functions + in consideration are small (and thus risk is small) and + moreover grow estimates already accounts that COMDAT + functions may or may not disappear when eliminated from + current unit. With good probability making aggressive + choice in all units is going to make overall program + smaller. */ + if (DECL_COMDAT (node->decl)) + { + if (!node->can_remove_if_no_direct_calls_p ()) + return true; + } + else if (!node->will_be_removed_from_program_if_no_direct_calls_p ()) + return true; + return estimate_growth (node) > 0; } |