public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Jan Hubicka <jh@suse.cz>, Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix hang in inline_small_functions (PR ipa/84425)
Date: Fri, 16 Feb 2018 22:49:00 -0000	[thread overview]
Message-ID: <20180216224944.GG5867@tucnak> (raw)

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.

--- 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);
+}

	Jakub

             reply	other threads:[~2018-02-16 22:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-16 22:49 Jakub Jelinek [this message]
2018-02-16 23:03 ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180216224944.GG5867@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jh@suse.cz \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).