Message ID | 20180216224944.GG5867@tucnak |
---|---|
State | New |
Headers | show |
Series | Fix hang in inline_small_functions (PR ipa/84425) | expand |
On 02/16/2018 03:49 PM, Jakub Jelinek wrote: > Hi! > > When debugging a wrong-code in miniruby on aarch64, I've noticed a hang > in inline_small_functions when adding __attribute__((optimize(0))) > to one of the functions. > > I don't know what exactly the code is doing, but it feels like a typo for > me, at least I'd expect the intent is for n2 to walk the whole chain, > rather than just the first 2 elements of it and then hope something changes > the ((struct ipa_dfs_info *) node->aux)->next_cycle to something different, > when the loop body is > if (opt_for_fn (n2->decl, optimize)) > { > struct ipa_fn_summary *info2 = ipa_fn_summaries->get (n2); > if (info2->scc_no) > break; > info2->scc_no = id; > } > and so for some n2's isn't doing anything and at least the method name get > doesn't suggest it would update something. > While the regression on this testcase is recent, I think the bug is latent > since 2012 when this code has been introduced. > > Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? > > 2018-02-16 Jakub Jelinek <jakub@redhat.com> > > PR ipa/84425 > * ipa-inline.c (inline_small_functions): Fix a typo. > > * gcc.c-torture/compile/pr84425.c: New test. Looks like a typo to me too. OK. jeff
--- gcc/ipa-inline.c.jj 2018-01-30 16:57:25.265095696 +0100 +++ gcc/ipa-inline.c 2018-02-16 20:53:54.803512238 +0100 @@ -1782,7 +1782,7 @@ inline_small_functions (void) struct cgraph_node *n2; int id = dfs->scc_no + 1; for (n2 = node; n2; - n2 = ((struct ipa_dfs_info *) node->aux)->next_cycle) + n2 = ((struct ipa_dfs_info *) n2->aux)->next_cycle) if (opt_for_fn (n2->decl, optimize)) { struct ipa_fn_summary *info2 = ipa_fn_summaries->get (n2); --- gcc/testsuite/gcc.c-torture/compile/pr84425.c.jj 2018-02-16 20:54:46.785534252 +0100 +++ gcc/testsuite/gcc.c-torture/compile/pr84425.c 2018-02-16 20:55:00.628540119 +0100 @@ -0,0 +1,17 @@ +/* PR ipa/84425 */ + +void bar (int); + +void +foo (int x) +{ + if (x < 5) + bar (x); +} + +__attribute__((optimize(0))) void +bar (int x) +{ + if (x > 10) + foo (x); +}