From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Cc: Chung-Lin Tang <chunglin.tang@gmail.com>,
Tobias Burnus <tobias@codesourcery.com>
Subject: [committed] openmp: Fix up finish_omp_target_clauses [PR108286]
Date: Thu, 5 Jan 2023 12:03:36 +0100 [thread overview]
Message-ID: <Y7auiK3sZ0VWIh/j@tucnak> (raw)
Hi!
The comment in the loop says that we shouldn't add a map clause if such
a clause exists already, but the loop was actually using OMP_CLAUSE_DECL
on any clause. Target construct can have various clauses which don't
have OMP_CLAUSE_DECL at all (e.g. nowait, device or if) or clause
where it means something different (e.g. privatization clauses, allocate,
depend).
So, only check OMP_CLAUSE_DECL on OMP_CLAUSE_MAP clauses.
Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk
so far.
2023-01-05 Jakub Jelinek <jakub@redhat.com>
PR c++/108286
* semantics.cc (finish_omp_target_clauses): Ignore clauses other than
OMP_CLAUSE_MAP.
* testsuite/libgomp.c++/pr108286.C: New test.
--- gcc/cp/semantics.cc.jj 2022-12-05 11:10:37.610673062 +0100
+++ gcc/cp/semantics.cc 2023-01-04 19:10:52.882277867 +0100
@@ -9825,7 +9825,9 @@ finish_omp_target_clauses (location_t lo
for (tree c = *clauses_ptr; c; c = OMP_CLAUSE_CHAIN (c))
{
- /* If map(this->ptr[:N] already exists, avoid creating another
+ if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_MAP)
+ continue;
+ /* If map(this->ptr[:N]) already exists, avoid creating another
such map. */
tree decl = OMP_CLAUSE_DECL (c);
if ((TREE_CODE (decl) == INDIRECT_REF
--- libgomp/testsuite/libgomp.c++/pr108286.C.jj 2023-01-04 19:21:07.401384587 +0100
+++ libgomp/testsuite/libgomp.c++/pr108286.C 2023-01-04 19:20:05.793276171 +0100
@@ -0,0 +1,29 @@
+// PR c++/108286
+// { dg-do run }
+
+struct S {
+ int
+ foo ()
+ {
+ int res = 0;
+#pragma omp target map(size, ptr[:size], res) nowait
+ res = ptr[size - 1];
+#pragma omp taskwait
+ return res;
+ }
+
+ unsigned size;
+ int *ptr;
+};
+
+int
+main ()
+{
+ S s;
+ int buf[5];
+ s.size = 5;
+ s.ptr = buf;
+ buf[4] = 42;
+ if (s.foo () != 42)
+ __builtin_abort ();
+}
Jakub
reply other threads:[~2023-01-05 11:03 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=Y7auiK3sZ0VWIh/j@tucnak \
--to=jakub@redhat.com \
--cc=chunglin.tang@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=tobias@codesourcery.com \
/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).