From: Jan Hubicka Date: Mon, 2 Mar 2015 20:31:21 +0000 (+0100) Subject: re PR lto/65130 (ICE with LTO on valid code on x86_64-linux-gnu) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1af8bfe51613a7ba044d1e7cc8d3e244c6daf8bc;p=gcc.git re PR lto/65130 (ICE with LTO on valid code on x86_64-linux-gnu) PR ipa/65130 * ipa-inline.c (check_callers): Looks for recursion. (inline_to_all_callers): Give up on uninlinable or recursive edges. * ipa-inline-analysis.c (inline_summary_t::duplicate): Do not update summary of inline clones. (do_estimate_growth_1): Fix recursion check. * gcc.dg/lto/pr65130_0.c: New testcase. * gcc.dg/lto/pr65130_1.c: New testcase. From-SVN: r221124 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f84b46281da..f9c093282b8 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +2015-03-02 Jan Hubicka + + PR ipa/65130 + * ipa-inline.c (check_callers): Looks for recursion. + (inline_to_all_callers): Give up on uninlinable or recursive edges. + * ipa-inline-analysis.c (inline_summary_t::duplicate): Do not update + summary of inline clones. + (do_estimate_growth_1): Fix recursion check. + 2015-03-02 Jan Hubicka PR ipa/64988 diff --git a/gcc/ipa-inline-analysis.c b/gcc/ipa-inline-analysis.c index be178ad445c..7a9c99cc512 100644 --- a/gcc/ipa-inline-analysis.c +++ b/gcc/ipa-inline-analysis.c @@ -1291,7 +1291,8 @@ inline_summary_t::duplicate (cgraph_node *src, set_hint_predicate (&info->array_index, p); } } - inline_update_overall_summary (dst); + if (!dst->global.inlined_to) + inline_update_overall_summary (dst); } @@ -3924,10 +3925,11 @@ do_estimate_growth_1 (struct cgraph_node *node, void *data) continue; } - if (e->caller == d->node - || (e->caller->global.inlined_to - && e->caller->global.inlined_to == d->node)) - d->self_recursive = true; + if (e->recursive_p ()) + { + d->self_recursive = true; + continue; + } d->growth += estimate_edge_growth (e); } return false; diff --git a/gcc/ipa-inline.c b/gcc/ipa-inline.c index db77d12e85f..0b38b4c6225 100644 --- a/gcc/ipa-inline.c +++ b/gcc/ipa-inline.c @@ -952,6 +952,8 @@ check_callers (struct cgraph_node *node, void *has_hot_call) return true; if (!can_inline_edge_p (e, true)) return true; + if (e->recursive_p ()) + return true; if (!(*(bool *)has_hot_call) && e->maybe_hot_p ()) *(bool *)has_hot_call = true; } @@ -2094,6 +2096,15 @@ inline_to_all_callers (struct cgraph_node *node, void *data) { struct cgraph_node *caller = node->callers->caller; + if (!can_inline_edge_p (node->callers, true) + || node->callers->recursive_p ()) + { + if (dump_file) + fprintf (dump_file, "Uninlinable call found; giving up.\n"); + *num_calls = 0; + return false; + } + if (dump_file) { fprintf (dump_file, diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 135f73498b4..4555c13782a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2015-03-02 Jan Hubicka + + PR ipa/65130 + * gcc.dg/lto/pr65130_0.c: New testcase. + * gcc.dg/lto/pr65130_1.c: New testcase. + 2015-03-02 Jan Hubicka PR ipa/64988 diff --git a/gcc/testsuite/gcc.dg/lto/pr65130_0.c b/gcc/testsuite/gcc.dg/lto/pr65130_0.c new file mode 100644 index 00000000000..5b68560d7ff --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr65130_0.c @@ -0,0 +1,19 @@ +/* { dg-lto-do link } */ +/* { dg-lto-options { { -flto -O1 -fdevirtualize } } } */ +extern void fn3 (void); + +void fn2(void) +{ + fn3(); +} + +void fn1(void) +{ + fn2(); +} + +void fn4(void) +{ + fn2(); +} + diff --git a/gcc/testsuite/gcc.dg/lto/pr65130_1.c b/gcc/testsuite/gcc.dg/lto/pr65130_1.c new file mode 100644 index 00000000000..1bfaa15ec75 --- /dev/null +++ b/gcc/testsuite/gcc.dg/lto/pr65130_1.c @@ -0,0 +1,17 @@ +/* { dg-options "-O2 -fdevirtualize" } */ +extern void fn1(void); +extern void fn4 (void); + +int a; + +void fn3(void) +{ + for (; a;) + fn4(); +} + +int main() { + fn1(); + return 0; +} +