public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Ian Lance Taylor <ian@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/gccgo] IPA: Avoid segfault in devirtualization_time_bonus (PR 93223)
Date: Thu, 23 Jan 2020 00:17:00 -0000	[thread overview]
Message-ID: <20200123001657.99787.qmail@sourceware.org> (raw)

https://gcc.gnu.org/g:8472660b98a31b32b7d030c2cdc4d41d326364d5

commit 8472660b98a31b32b7d030c2cdc4d41d326364d5
Author: Martin Jambor <mjambor@suse.cz>
Date:   Mon Jan 13 19:13:46 2020 +0100

    IPA: Avoid segfault in devirtualization_time_bonus (PR 93223)
    
    2020-01-13  Martin Jambor  <mjambor@suse.cz>
    
    	PR ipa/93223
    	* ipa-cp.c (devirtualization_time_bonus): Check whether isummary is
    	NULL.
    
    	testsuite/
    	* g++.dg/ipa/pr93223.C: New test.

Diff:
---
 gcc/ipa-cp.c                       |  2 +-
 gcc/testsuite/g++.dg/ipa/pr93223.C | 62 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/gcc/ipa-cp.c b/gcc/ipa-cp.c
index 612f3d0..17da1d8 100644
--- a/gcc/ipa-cp.c
+++ b/gcc/ipa-cp.c
@@ -3158,7 +3158,7 @@ devirtualization_time_bonus (struct cgraph_node *node,
       if (avail < AVAIL_AVAILABLE)
 	continue;
       isummary = ipa_fn_summaries->get (callee);
-      if (!isummary->inlinable)
+      if (!isummary || !isummary->inlinable)
 	continue;
 
       int size = ipa_size_summaries->get (callee)->size;
diff --git a/gcc/testsuite/g++.dg/ipa/pr93223.C b/gcc/testsuite/g++.dg/ipa/pr93223.C
new file mode 100644
index 0000000..87f98b5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/ipa/pr93223.C
@@ -0,0 +1,62 @@
+/* { dg-do compile } */
+/* { dg-options "-O3 -std=gnu++14" } */
+
+template <typename Function>
+bool run(const int item_count,
+         Function && process_range,
+         const int max_parallelism,
+         int* progress = nullptr)
+{
+    if (max_parallelism <= 1)
+    {
+        if (progress == nullptr)
+        {
+            return process_range(0);
+        }
+        else
+        {
+            auto result = true;
+            for (int i = 0; i != item_count && result; ++i)
+            {
+                (*progress)++;
+                result = process_range(i);
+            }
+            return result;
+        }
+    }
+
+    if (max_parallelism > 10)
+    {
+        if (progress == nullptr)
+        {
+            return process_range(0);
+        }
+        else
+        {
+            auto result = true;
+            for (int i = 0; i != item_count && result; ++i)
+            {
+                (*progress)++;
+                result = process_range(i);
+            }
+            return result;
+        }
+    }
+    return false;
+}
+
+namespace
+{
+__attribute__((optimize(0))) bool worker_fun(const int)
+{
+    return true;
+}
+}
+
+void demo(int n)
+{
+    for (int i = 0; i < n; ++i)
+    {
+        run(n, &worker_fun, n);
+    }
+}


                 reply	other threads:[~2020-01-23  0:16 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20200123001657.99787.qmail@sourceware.org \
    --to=ian@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).