public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Chung-Lin Tang <cltang@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>,
	Tobias Burnus <tobias@codesourcery.com>
Subject: Re: [PATCH, OpenMP] PR103642 - Fix omp-low ICE for indirect references based off component access
Date: Tue, 18 Jan 2022 15:09:45 +0100	[thread overview]
Message-ID: <20220118140945.GB2646553@tucnak> (raw)
In-Reply-To: <7233befe-4c44-b275-c4ac-82af937f32f0@codesourcery.com>

On Mon, Jan 03, 2022 at 10:15:26PM +0800, Chung-Lin Tang wrote:
> This issue was triggered after the patch extending syntax for component access
> in map clauses
> (https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=0ab29cf0bb68960c)
> 
> In gimplify_scan_omp_clauses, the case for handling indirect accesses (which creates
> firstprivate ptr and zero-length array section map for such decls) was erroneously
> went into for non-pointer cases (here being the base struct decl), so added the
> appropriate checks there.
> 
> Added new testcase is a compile only test for the ICE. The original omptests t-partial-struct
> test actually should not execute correctly, because for map(t.s->a[:N]), map(t.s[:1])
> is not implicitly mapped, thus the entire offloaded access does not work as is.
> (fixing that omptests test is out of scope here)
> 
> Tested without regressions, okay for trunk?
> 
> Thanks,
> Chung-Lin
> 
> 2022-01-03  Chung-Lin Tang  <cltang@codesourcery.com>
> 
> gcc/ChangeLog:
> 
> 	PR middle-end/103642
> 	* gimplify.c (gimplify_scan_omp_clauses): Do not do indir_p handling
> 	for non-pointer or non-reference-to-pointer cases.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* c-c++-common/gomp/pr103642.c: New test.

Ok, with a small nit:

> +int main (void)
> +{
> +  T t;
> +  t.s = (S *) malloc (sizeof (S));
> +  t.s->a = (int *) malloc (sizeof(int) * N);
> +
> +  #pragma omp target map(from: t.s->a[:N])
> +  {
> +    t.s->a[0] = 1;
> +  }

Please free the pointers afterwards.

	Jakub


      parent reply	other threads:[~2022-01-18 14:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-03 14:15 Chung-Lin Tang
2022-01-17 14:55 ` Chung-Lin Tang
2022-01-18 14:09 ` Jakub Jelinek [this message]

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=20220118140945.GB2646553@tucnak \
    --to=jakub@redhat.com \
    --cc=cltang@codesourcery.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).