public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "burnus at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgomp/113867] [14 Regression][OpenMP] Wrong code with mapping pointers in structs
Date: Wed, 21 Feb 2024 17:59:58 +0000	[thread overview]
Message-ID: <bug-113867-4-SVEfhugrxh@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-113867-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113867

--- Comment #5 from Tobias Burnus <burnus at gcc dot gnu.org> ---
For:

  int *q;
  #pragma omp target device(y5) map(q, q[:5])

GCC currently generates:
  map(tofrom:q [len: 8]) map(tofrom:*q.4_1 [len: 20]) map(attach:q [bias: 0])

Expected:
  'alloc:' instead of 'attach:'
or even:
  map(tofrom:*q [len: 20]) map(firstprivate:q [pointer assign, bias: 0])

In any case, the first 'tofrom' is pointless!


NOTE: GCC 13 shows:
  error: 'q' appears both in data and map clauses

 * * *

For
  #pragma omp target map(s.p[:5])

GCC should do:
  map(tofrom:s [len: 24][implicit]) map(tofrom:*_5 [len: 16])
    map(attach:s.p [bias: 0])

But (regression!) it does:
  map(struct:s [len: 1]) map(alloc:s.p [len: 8]) map(tofrom:*_5 [len: 16])
    map(attach:s.p [bias: 0])

Solution:

--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -12381,3 +12381,4 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq
*pre_p,
              if (OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH
-                 || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH)
+                 || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_DETACH
+                 || OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ATTACH_DETACH)
                break;


However, unless I messed up, this will cause tons of ICE(segfault).

  parent reply	other threads:[~2024-02-21 17:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-10 18:01 [Bug middle-end/113867] New: " burnus at gcc dot gnu.org
2024-02-10 18:07 ` [Bug middle-end/113867] " burnus at gcc dot gnu.org
2024-02-12  8:45 ` rguenth at gcc dot gnu.org
2024-02-12 12:30 ` [Bug libgomp/113867] " burnus at gcc dot gnu.org
2024-02-12 13:00 ` burnus at gcc dot gnu.org
2024-02-13 10:43 ` burnus at gcc dot gnu.org
2024-02-21 17:59 ` burnus at gcc dot gnu.org [this message]
2024-03-07 20:40 ` law at gcc dot gnu.org
2024-04-03 12:02 ` rguenth at gcc dot gnu.org
2024-04-26  8:42 ` jakub at gcc dot gnu.org
2024-05-07  7:45 ` [Bug libgomp/113867] [14/15 " rguenth at gcc dot gnu.org

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=bug-113867-4-SVEfhugrxh@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).