This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [openacc] implicit non-scalars data mapping in kernels
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: Cesar Philippidis <cesar at codesourcery dot com>, "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>, Nathan Sidwell <nathan_sidwell at mentor dot com>
- Date: Wed, 13 Jan 2016 23:44:26 +0100
- Subject: Re: [openacc] implicit non-scalars data mapping in kernels
- Authentication-results: sourceware.org; auth=none
- References: <5696CFC1 dot 9060004 at codesourcery dot com> <20160113223508 dot GM25528 at redhat dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Wed, Jan 13, 2016 at 11:35:08PM +0100, Marek Polacek wrote:
> On Wed, Jan 13, 2016 at 02:29:21PM -0800, Cesar Philippidis wrote:
> > --- a/gcc/gimplify.c
> > +++ b/gcc/gimplify.c
> > @@ -5994,6 +5994,11 @@ oacc_default_clause (struct gimplify_omp_ctx *ctx, tree decl, unsigned flags)
> > {
> > const char *rkind;
> > bool on_device = false;
> > + tree type = TREE_TYPE (decl);
> > +
> > + if (TREE_CODE (type) == REFERENCE_TYPE
> > + || POINTER_TYPE_P (type))
>
> I think this should be just POINTER_TYPE_P--this macro checks for
> REFERENCE_TYPE as well.
Unless the spec says that for all pointers you should consider what it
points to, this really looks weird to me.
Say for OpenMP, I usually use
lang_hooks.decls.omp_privatize_by_reference (decl)
hook for similar purposes where the FEs have the possibility to say
if you are interested in the pointer/reference itself or what it points to,
which is just always false for C, for C++ REFERENCE_TYPE vars and
invisiref stuff, and for Fortran various.
So I'd expect to see instead
tree type = TREE_TYPE (decl);
if (lang_hooks.decls.omp_privatize_by_reference (decl))
type = TREE_TYPE (type);
or so. Just looking at TREE_TYPE of arbitrary POINTER_TYPE_P has also the
disadvantage that the pointer can be void *, or pointer to incomplete type,
...
Jakub