From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 707AB383A33A for ; Tue, 24 May 2022 13:39:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 707AB383A33A Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-638-3mOwsBqeMcWGb4rd335W1Q-1; Tue, 24 May 2022 09:39:52 -0400 X-MC-Unique: 3mOwsBqeMcWGb4rd335W1Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 936463C025B0; Tue, 24 May 2022 13:39:51 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.106]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4A53D40D1B98; Tue, 24 May 2022 13:39:51 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 24ODdm1a2107061 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 24 May 2022 15:39:48 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 24ODdlOQ2107060; Tue, 24 May 2022 15:39:47 +0200 Date: Tue, 24 May 2022 15:39:47 +0200 From: Jakub Jelinek To: Julian Brown Cc: gcc-patches@gcc.gnu.org, Thomas Schwinge , Tobias Burnus , Fortran List Subject: Re: [PATCH v2 05/11] OpenMP: Handle reference-typed struct members Message-ID: Reply-To: Jakub Jelinek References: <5084d165c33b382d71b44eaf9e5f3ffdb87bbcfc.1647619144.git.julian@codesourcery.com> MIME-Version: 1.0 In-Reply-To: <5084d165c33b382d71b44eaf9e5f3ffdb87bbcfc.1647619144.git.julian@codesourcery.com> X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: fortran@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Fortran mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 24 May 2022 13:39:56 -0000 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