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 711783858D39 for ; Tue, 18 Jan 2022 14:10:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 711783858D39 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-460-pG-3G3tIMoShxnnSNNWTaw-1; Tue, 18 Jan 2022 09:10:32 -0500 X-MC-Unique: pG-3G3tIMoShxnnSNNWTaw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DD8898C13C2; Tue, 18 Jan 2022 14:10:07 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.40.192.74]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1230934D4D; Tue, 18 Jan 2022 14:10:04 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 20IE9pmB3092953 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 18 Jan 2022 15:09:51 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 20IE9kp43092952; Tue, 18 Jan 2022 15:09:46 +0100 Date: Tue, 18 Jan 2022 15:09:45 +0100 From: Jakub Jelinek To: Chung-Lin Tang Cc: gcc-patches , Tobias Burnus Subject: Re: [PATCH, OpenMP] PR103642 - Fix omp-low ICE for indirect references based off component access Message-ID: <20220118140945.GB2646553@tucnak> Reply-To: Jakub Jelinek References: <7233befe-4c44-b275-c4ac-82af937f32f0@codesourcery.com> MIME-Version: 1.0 In-Reply-To: <7233befe-4c44-b275-c4ac-82af937f32f0@codesourcery.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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=-5.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jan 2022 14:10:39 -0000 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 > > 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