public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Marcel Vollweiler <marcel@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-12] openmp: Bugfix in omp_expand_metadirective for same blocks/edges to be deleted.
Date: Tue,  1 Nov 2022 13:11:03 +0000 (GMT)	[thread overview]
Message-ID: <20221101131103.844F23858418@sourceware.org> (raw)

https://gcc.gnu.org/g:dc2304b3ce7e96094d50fe48bf790be6b4d6f02e

commit dc2304b3ce7e96094d50fe48bf790be6b4d6f02e
Author: Marcel Vollweiler <marcel@codesourcery.com>
Date:   Tue Nov 1 13:05:18 2022 +0000

    openmp: Bugfix in omp_expand_metadirective for same blocks/edges to be deleted.
    
    This patch handles an ICE that is thrown in omp_expand_metadirective when a
    basic_block for a metadirective label is tried to be deleted multiple times.
    To avoid this situation, processed labels are added to the already existing
    list of labels that are not intended to be deleted.
    
    The issue occured in the attached test case.
    
    gcc/ChangeLog:
    
            * omp-expand-metadirective.cc (omp_expand_metadirective): Add already
            processed labels to "labels" (the list of labels not to be deleted).
    
    gcc/testsuite/ChangeLog:
    
            * c-c++-common/gomp/metadirective-8.c: New test.

Diff:
---
 gcc/ChangeLog.omp                                 |  5 +++++
 gcc/omp-expand-metadirective.cc                   |  1 +
 gcc/testsuite/ChangeLog.omp                       |  4 ++++
 gcc/testsuite/c-c++-common/gomp/metadirective-8.c | 16 ++++++++++++++++
 4 files changed, 26 insertions(+)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index f8d5af30ca5..b636fa5baf4 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,8 @@
+2022-11-01  Marcel Vollweiler  <marcel@codesourcery.com>
+
+	* omp-expand-metadirective.cc (omp_expand_metadirective): Add already
+	processed labels to "labels" (the list of labels not to be deleted).
+
 2022-11-01  Andrew Stubbs  <ams@codesourcery.com>
 
 	Backport from mainline:
diff --git a/gcc/omp-expand-metadirective.cc b/gcc/omp-expand-metadirective.cc
index aaf048a699a..0e885e98592 100644
--- a/gcc/omp-expand-metadirective.cc
+++ b/gcc/omp-expand-metadirective.cc
@@ -65,6 +65,7 @@ omp_expand_metadirective (function *fun, basic_block bb)
 	{
 	  edge e = find_edge (bb, label_to_block (fun, label));
 	  remove_edge_and_dominated_blocks (e);
+	  labels.safe_push (label);
 	}
     }
 
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index ef76bf2bbb3..3ae28694624 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,7 @@
+2022-11-01  Marcel Vollweiler  <marcel@codesourcery.com>
+
+	* c-c++-common/gomp/metadirective-8.c: New test.
+
 2022-10-28  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backport from mainline:
diff --git a/gcc/testsuite/c-c++-common/gomp/metadirective-8.c b/gcc/testsuite/c-c++-common/gomp/metadirective-8.c
new file mode 100644
index 00000000000..c7d9c31ed73
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/metadirective-8.c
@@ -0,0 +1,16 @@
+/* { dg-do compile } */
+
+#define N 256
+
+void f ()
+{
+  int i;
+  int a[N];
+
+  #pragma omp metadirective \
+      when( device={kind(nohost)}: nothing ) \
+      when( device={arch("nvptx")}: nothing) \
+      default( parallel for)
+    for (i = 0; i < N; i++)
+      a[i] = i;
+}

                 reply	other threads:[~2022-11-01 13:11 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=20221101131103.844F23858418@sourceware.org \
    --to=marcel@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).