From patchwork Mon Jun 19 21:17:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 1796800 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QlN0h5QV3z20Wk for ; Tue, 20 Jun 2023 07:18:28 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B1BCA385C6F2 for ; Mon, 19 Jun 2023 21:18:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id D0D0B3858289; Mon, 19 Jun 2023 21:18:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D0D0B3858289 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="6.00,255,1681200000"; d="scan'208";a="9264346" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa4.mentor.iphmx.com with ESMTP; 19 Jun 2023 13:18:03 -0800 IronPort-SDR: /CjcS04FMBgJwSlA36VtTdYA2WP6wdvbeIUqKIHylqvL3MWErKtnGVrBE7kGleUG0FDcbvxLpf I8ADO/oW4S9rs7GTZz+4Sag7BkSF/rcdTnvn1oUGUhpGasQdU59VxTFSOca/Zrt4WsKZJ7XhJs she6x4Uxpx1iCZgn2mggUKSNIoTO+n8hzndhFD9yn/85MSnoYRqrMiV3hRBmX3mD+fehyj1Xfq zF5eXQ7nDZWmAOV1iwtZYfYEftAaTJE1iQvENaQ1R2WcwY0NaDIp42JzrTYBPWrJ2Ks4uk1GN5 jFE= From: Julian Brown To: CC: , , Subject: [PATCH 04/14] Revert "openmp: Handle C/C++ array reference base-pointers in array sections" Date: Mon, 19 Jun 2023 21:17:28 +0000 Message-ID: <8db32dad90f031f27674ee9913f8db04046fa6d6.1687201315.git.julian@codesourcery.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-15.mgc.mentorg.com (139.181.222.15) To svr-ies-mbx-11.mgc.mentorg.com (139.181.222.11) X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, 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: 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: , Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" This reverts commit 3385743fd2fa15a2a750a29daf6d4f97f5aad0ae. 2023-06-16 Julian Brown Revert: 2022-02-24 Chung-Lin Tang gcc/c/ChangeLog: * c-typeck.cc (handle_omp_array_sections): Add handling for creating array-reference base-pointer attachment clause. gcc/cp/ChangeLog: * semantics.cc (handle_omp_array_sections): Add handling for creating array-reference base-pointer attachment clause. gcc/testsuite/ChangeLog: * c-c++-common/gomp/target-enter-data-1.c: Adjust testcase. libgomp/ChangeLog: * testsuite/libgomp.c-c++-common/ptr-attach-2.c: New test. --- gcc/c/c-typeck.cc | 27 +-------- gcc/cp/semantics.cc | 28 +-------- .../c-c++-common/gomp/target-enter-data-1.c | 3 +- .../libgomp.c-c++-common/ptr-attach-2.c | 60 ------------------- 4 files changed, 3 insertions(+), 115 deletions(-) delete mode 100644 libgomp/testsuite/libgomp.c-c++-common/ptr-attach-2.c diff --git a/gcc/c/c-typeck.cc b/gcc/c/c-typeck.cc index 450214556f9..9591d67251e 100644 --- a/gcc/c/c-typeck.cc +++ b/gcc/c/c-typeck.cc @@ -14113,10 +14113,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) if (int_size_in_bytes (TREE_TYPE (first)) <= 0) maybe_zero_len = true; - struct dim { tree low_bound, length; }; - auto_vec dims (num); - dims.safe_grow (num); - for (i = num, t = OMP_CLAUSE_DECL (c); i > 0; t = TREE_CHAIN (t)) { @@ -14238,9 +14234,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) else size = size_binop (MULT_EXPR, size, l); } - - dim d = { low_bound, length }; - dims[i] = d; } if (non_contiguous) { @@ -14288,23 +14281,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) OMP_CLAUSE_DECL (c) = t; return false; } - - tree aref = t; - for (i = 0; i < dims.length (); i++) - { - if (dims[i].length && integer_onep (dims[i].length)) - { - tree lb = dims[i].low_bound; - aref = build_array_ref (OMP_CLAUSE_LOCATION (c), aref, lb); - } - else - { - if (TREE_CODE (TREE_TYPE (aref)) == POINTER_TYPE) - t = aref; - break; - } - } - first = c_fully_fold (first, false, NULL); OMP_CLAUSE_DECL (c) = first; if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR) @@ -14339,8 +14315,7 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) break; } tree c2 = build_omp_clause (OMP_CLAUSE_LOCATION (c), OMP_CLAUSE_MAP); - if (TREE_CODE (t) == COMPONENT_REF || TREE_CODE (t) == ARRAY_REF - || TREE_CODE (t) == INDIRECT_REF) + if (TREE_CODE (t) == COMPONENT_REF) OMP_CLAUSE_SET_MAP_KIND (c2, GOMP_MAP_ATTACH_DETACH); else OMP_CLAUSE_SET_MAP_KIND (c2, GOMP_MAP_FIRSTPRIVATE_POINTER); diff --git a/gcc/cp/semantics.cc b/gcc/cp/semantics.cc index e7bda6fa060..93ff7cf5e1b 100644 --- a/gcc/cp/semantics.cc +++ b/gcc/cp/semantics.cc @@ -5605,10 +5605,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) if (processing_template_decl && maybe_zero_len) return false; - struct dim { tree low_bound, length; }; - auto_vec dims (num); - dims.safe_grow (num); - for (i = num, t = OMP_CLAUSE_DECL (c); i > 0; t = TREE_CHAIN (t)) { @@ -5728,9 +5724,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) else size = size_binop (MULT_EXPR, size, l); } - - dim d = { low_bound, length }; - dims[i] = d; } if (!processing_template_decl) { @@ -5782,24 +5775,6 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) OMP_CLAUSE_DECL (c) = t; return false; } - - tree aref = t; - for (i = 0; i < dims.length (); i++) - { - if (dims[i].length && integer_onep (dims[i].length)) - { - tree lb = dims[i].low_bound; - aref = convert_from_reference (aref); - aref = build_array_ref (OMP_CLAUSE_LOCATION (c), aref, lb); - } - else - { - if (TREE_CODE (TREE_TYPE (aref)) == POINTER_TYPE) - t = aref; - break; - } - } - OMP_CLAUSE_DECL (c) = first; if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_HAS_DEVICE_ADDR) return false; @@ -5841,8 +5816,7 @@ handle_omp_array_sections (tree c, enum c_omp_region_type ort) bool reference_always_pointer = true; tree c2 = build_omp_clause (OMP_CLAUSE_LOCATION (c), OMP_CLAUSE_MAP); - if (TREE_CODE (t) == COMPONENT_REF || TREE_CODE (t) == ARRAY_REF - || (TREE_CODE (t) == INDIRECT_REF && !REFERENCE_REF_P (t))) + if (TREE_CODE (t) == COMPONENT_REF) { OMP_CLAUSE_SET_MAP_KIND (c2, GOMP_MAP_ATTACH_DETACH); diff --git a/gcc/testsuite/c-c++-common/gomp/target-enter-data-1.c b/gcc/testsuite/c-c++-common/gomp/target-enter-data-1.c index 3a1b488fa1f..ce766d29e2d 100644 --- a/gcc/testsuite/c-c++-common/gomp/target-enter-data-1.c +++ b/gcc/testsuite/c-c++-common/gomp/target-enter-data-1.c @@ -21,5 +21,4 @@ void func (struct foo *f, int n, int m) #pragma omp target enter data map (to: f->bars[n].vectors[:f->bars[n].num_vectors]) } -/* { dg-final { scan-tree-dump-times "map\\(to:\\*_\[0-9\]+ \\\[len: _\[0-9\]+\\\]\\) map\\(attach:\\*_\[0-9\]+ \\\[bias: \[^\]\]+\\\]\\)" 1 "gimple" } } */ -/* { dg-final { scan-tree-dump-times "map\\(to:\\*_\[0-9\]+ \\\[len: _\[0-9\]+\\\]\\) map\\(attach:\[^-\]+->vectors \\\[bias: \[^\]\]+\\\]\\)" 2 "gimple" } } */ +/* { dg-final { scan-tree-dump-times "map\\(to:\\*_\[0-9\]+ \\\[len: _\[0-9\]+\\\]\\) map\\(attach:\[^-\]+->vectors \\\[bias: \[^\]\]+\\\]\\)" 3 "gimple" } } */ diff --git a/libgomp/testsuite/libgomp.c-c++-common/ptr-attach-2.c b/libgomp/testsuite/libgomp.c-c++-common/ptr-attach-2.c deleted file mode 100644 index 889a4a253ae..00000000000 --- a/libgomp/testsuite/libgomp.c-c++-common/ptr-attach-2.c +++ /dev/null @@ -1,60 +0,0 @@ -#include - -struct blk { int x, y; }; -struct L -{ - #define N 10 - struct { - int num_blocks[N]; - struct blk * blocks[N]; - } m; -}; - -void foo (struct L *l) -{ - for (int i = 0; i < N; i++) - { - l->m.blocks[i] = (struct blk *) malloc (sizeof (struct blk) * N); - l->m.num_blocks[i] = N; - } - - #pragma omp target enter data map(to:l[:1]) - for (int i = 0; i < N; i++) - { - #pragma omp target enter data map(to:l->m.blocks[i][:l->m.num_blocks[i]]) - } - - #pragma omp target - { - for (int i = 0; i < N; i++) - for (int j = 0; j < N; j++) - { - l->m.blocks[i][j].x = i + j; - l->m.blocks[i][j].y = i * j; - } - } - - for (int i = 0; i < N; i++) - { - #pragma omp target exit data map(from:l->m.blocks[i][:l->m.num_blocks[i]]) - } - #pragma omp target exit data map(from:l[:1]) - - - for (int i = 0; i < N; i++) - for (int j = 0; j < N; j++) - { - if (l->m.blocks[i][j].x != i + j) - abort (); - if (l->m.blocks[i][j].y != i * j) - abort (); - } - -} - -int main (void) -{ - struct L l; - foo (&l); - return 0; -}