[PATCH v2 05/11] OpenMP: Handle reference-typed struct members
Jakub Jelinek
jakub@redhat.com
Tue May 24 13:39:47 GMT 2022
On Fri, Mar 18, 2022 at 09:26:46AM -0700, Julian Brown wrote:
> This patch relates to OpenMP mapping clauses containing struct members of
> reference type, e.g. "mystruct.myref.myptr[:N]". To be able to access
> the array slice through the reference in the middle, we need to perform
> an attach action for that reference, since it is represented internally
> as a pointer.
>
> I don't think the spec allows for this case explicitly. The closest
> clause is (OpenMP 5.0, "2.19.7.1 map Clause"):
>
> "If the type of a list item is a reference to a type T then the
> reference in the device data environment is initialized to refer to
> the object in the device data environment that corresponds to the
> object referenced by the list item. If mapping occurs, it occurs as
> though the object were mapped through a pointer with an array section
> of type T and length one."
Plus the general rule that aggregates are mapped as mapping of all its
individual members/elements.
> --- a/gcc/gimplify.cc
> +++ b/gcc/gimplify.cc
> @@ -9813,7 +9813,10 @@ accumulate_sibling_list (enum omp_region_type region_type, enum tree_code code,
> /* FIXME: If we're not mapping the base pointer in some other clause on this
> directive, I think we want to create ALLOC/RELEASE here -- i.e. not
> early-exit. */
> - if (openmp && attach_detach)
> + if (openmp
> + && attach_detach
> + && !(TREE_CODE (TREE_TYPE (ocd)) == REFERENCE_TYPE
> + && TREE_CODE (TREE_TYPE (TREE_TYPE (ocd))) != POINTER_TYPE))
> return NULL;
Why isn't a reference to pointer handled that way too?
Jakub
More information about the Gcc-patches
mailing list