From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1709) id E958A38515D4; Mon, 31 May 2021 09:02:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E958A38515D4 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Chung-Lin Tang To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-11] Revert "Fix template case of non-static member access inside member functions" X-Act-Checkin: gcc X-Git-Author: Chung-Lin Tang X-Git-Refname: refs/heads/devel/omp/gcc-11 X-Git-Oldrev: a9458daf1368df52a03cb97968e5d546b4b993af X-Git-Newrev: 97e9ff46502dc2e7b495b682dba063708e9da8aa Message-Id: <20210531090232.E958A38515D4@sourceware.org> Date: Mon, 31 May 2021 09:02:32 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 31 May 2021 09:02:33 -0000 https://gcc.gnu.org/g:97e9ff46502dc2e7b495b682dba063708e9da8aa commit 97e9ff46502dc2e7b495b682dba063708e9da8aa Author: Chung-Lin Tang Date: Wed May 26 19:11:49 2021 +0800 Revert "Fix template case of non-static member access inside member functions" This reverts commit 56314e382995ebbf35f77b9a2542b5411b9ae755. Diff: --- gcc/cp/semantics.c | 45 ++++++--------------------- gcc/gimplify.c | 19 ----------- gcc/testsuite/g++.dg/gomp/target-this-3.C | 2 +- gcc/testsuite/g++.dg/gomp/target-this-4.C | 2 +- gcc/testsuite/g++.dg/gomp/target-this-5.C | 34 -------------------- libgomp/testsuite/libgomp.c++/target-this-5.C | 30 ------------------ 6 files changed, 12 insertions(+), 120 deletions(-) diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 2eeab999841..6a71338fde9 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -6597,7 +6597,6 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) bool order_seen = false; bool schedule_seen = false; bool oacc_async = false; - bool indirect_ref_p = false; bool indir_component_ref_p = false; tree last_iterators = NULL_TREE; bool last_iterators_remove = false; @@ -7846,14 +7845,6 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) indir_component_ref_p = true; STRIP_NOPS (t); } - indirect_ref_p = false; - if ((ort == C_ORT_ACC || ort == C_ORT_OMP) - && INDIRECT_REF_P (t)) - { - t = TREE_OPERAND (t, 0); - indirect_ref_p = true; - STRIP_NOPS (t); - } if (TREE_CODE (t) == COMPONENT_REF && ((ort & C_ORT_OMP_DECLARE_SIMD) == C_ORT_OMP || ort == C_ORT_ACC) @@ -7889,12 +7880,6 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) break; } t = TREE_OPERAND (t, 0); - if (INDIRECT_REF_P (t)) - { - t = TREE_OPERAND (t, 0); - indir_component_ref_p = true; - STRIP_NOPS (t); - } } if (remove) break; @@ -7958,7 +7943,6 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) || (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FIRSTPRIVATE_POINTER)) && !indir_component_ref_p - && !indirect_ref_p && !cxx_mark_addressable (t)) remove = true; else if (!(OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP @@ -8053,8 +8037,7 @@ finish_omp_clauses (tree clauses, enum c_omp_region_type ort) } else { - if (!indirect_ref_p && !indir_component_ref_p) - bitmap_set_bit (&map_head, DECL_UID (t)); + bitmap_set_bit (&map_head, DECL_UID (t)); if (t != OMP_CLAUSE_DECL (c) && TREE_CODE (OMP_CLAUSE_DECL (c)) == COMPONENT_REF) bitmap_set_bit (&map_field_head, DECL_UID (t)); @@ -9115,12 +9098,9 @@ finish_omp_target (location_t loc, tree clauses, tree body, bool combined_p) tree closure = DECL_ARGUMENTS (current_function_decl); tree c = build_omp_clause (loc, OMP_CLAUSE_MAP); OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_TO); - OMP_CLAUSE_DECL (c) - = build_indirect_ref (loc, closure, RO_UNARY_STAR); + OMP_CLAUSE_DECL (c) = build_simple_mem_ref (closure); OMP_CLAUSE_SIZE (c) - = (processing_template_decl - ? NULL_TREE - : TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (closure)))); + = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (closure))); tree c2 = build_omp_clause (loc, OMP_CLAUSE_MAP); OMP_CLAUSE_SET_MAP_KIND (c2, GOMP_MAP_FIRSTPRIVATE_POINTER); @@ -9140,8 +9120,7 @@ finish_omp_target (location_t loc, tree clauses, tree body, bool combined_p) /* Transform *this into *__closure->this in maps. */ tree this_map = *explicit_this_deref_map; OMP_CLAUSE_DECL (this_map) - = build_indirect_ref (loc, omp_target_this_expr, RO_UNARY_STAR); - + = build_simple_mem_ref (omp_target_this_expr); tree nc = OMP_CLAUSE_CHAIN (this_map); gcc_assert (OMP_CLAUSE_CODE (nc) == OMP_CLAUSE_MAP && (OMP_CLAUSE_MAP_KIND (nc) @@ -9161,11 +9140,9 @@ finish_omp_target (location_t loc, tree clauses, tree body, bool combined_p) tree c3 = build_omp_clause (loc, OMP_CLAUSE_MAP); OMP_CLAUSE_SET_MAP_KIND (c3, GOMP_MAP_TOFROM); OMP_CLAUSE_DECL (c3) - = build_indirect_ref (loc, omp_target_this_expr, RO_UNARY_STAR); + = build_simple_mem_ref (omp_target_this_expr); OMP_CLAUSE_SIZE (c3) - = (processing_template_decl - ? NULL_TREE - : TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (omp_target_this_expr)))); + = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (omp_target_this_expr))); tree c4 = build_omp_clause (loc, OMP_CLAUSE_MAP); OMP_CLAUSE_SET_MAP_KIND (c4, GOMP_MAP_ALWAYS_POINTER); @@ -9187,12 +9164,9 @@ finish_omp_target (location_t loc, tree clauses, tree body, bool combined_p) { tree c = build_omp_clause (loc, OMP_CLAUSE_MAP); OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_TOFROM); - OMP_CLAUSE_DECL (c) - = build_indirect_ref (loc, omp_target_this_expr, RO_UNARY_STAR); + OMP_CLAUSE_DECL (c) = build_simple_mem_ref (omp_target_this_expr); OMP_CLAUSE_SIZE (c) - = (processing_template_decl - ? NULL_TREE - : TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (omp_target_this_expr)))); + = TYPE_SIZE_UNIT (TREE_TYPE (TREE_TYPE (omp_target_this_expr))); tree c2 = build_omp_clause (loc, OMP_CLAUSE_MAP); OMP_CLAUSE_SET_MAP_KIND (c2, GOMP_MAP_FIRSTPRIVATE_POINTER); @@ -9274,7 +9248,8 @@ finish_omp_target (location_t loc, tree clauses, tree body, bool combined_p) tree c = build_omp_clause (loc, OMP_CLAUSE_MAP); OMP_CLAUSE_SET_MAP_KIND (c, GOMP_MAP_ALLOC); OMP_CLAUSE_DECL (c) - = build_indirect_ref (loc, ptr_member, RO_UNARY_STAR); + = build2 (MEM_REF, char_type_node, ptr_member, + build_int_cst (build_pointer_type (char_type_node), 0)); OMP_CLAUSE_SIZE (c) = size_zero_node; OMP_CLAUSE_MAP_MAYBE_ZERO_LENGTH_ARRAY_SECTION (c) = 1; diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 8720f876359..e233db2bd55 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -9321,7 +9321,6 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, { indir_p = true; decl = TREE_OPERAND (decl, 0); - STRIP_NOPS (decl); } if (TREE_CODE (decl) == INDIRECT_REF && DECL_P (TREE_OPERAND (decl, 0)) @@ -9733,24 +9732,6 @@ gimplify_scan_omp_clauses (tree *list_p, gimple_seq *pre_p, break; } - /* If this was of the form map(*pointer_to_struct), then the - 'pointer_to_struct' DECL should be considered deref'ed. */ - if ((OMP_CLAUSE_MAP_KIND (c) == GOMP_MAP_ALLOC - || GOMP_MAP_COPY_TO_P (OMP_CLAUSE_MAP_KIND (c)) - || GOMP_MAP_COPY_FROM_P (OMP_CLAUSE_MAP_KIND (c))) - && INDIRECT_REF_P (orig_decl) - && DECL_P (TREE_OPERAND (orig_decl, 0)) - && TREE_CODE (TREE_TYPE (orig_decl)) == RECORD_TYPE) - { - tree ptr = TREE_OPERAND (orig_decl, 0); - if (!struct_deref_set || !struct_deref_set->contains (ptr)) - { - if (!struct_deref_set) - struct_deref_set = new hash_set (); - struct_deref_set->add (ptr); - } - } - if (!remove && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ALWAYS_POINTER && OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_ATTACH_DETACH diff --git a/gcc/testsuite/g++.dg/gomp/target-this-3.C b/gcc/testsuite/g++.dg/gomp/target-this-3.C index 08568f9284c..a450b3723e5 100644 --- a/gcc/testsuite/g++.dg/gomp/target-this-3.C +++ b/gcc/testsuite/g++.dg/gomp/target-this-3.C @@ -102,4 +102,4 @@ int main (void) /* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(tofrom:\*this \[len: [0-9]+\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\) map\(alloc:\*_[0-9]+ \[pointer assign, zero-length array section, bias: 0\]\) map\(attach:this->refptr \[bias: 0\]\) map\(from:mapped \[len: [0-9]+\]\) map\(alloc:\*_[0-9+] \[len: 0\]\) firstprivate\(n\)} "gimple" } } */ -/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(tofrom:\*this \[len: [0-9]+\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\) map\(attach_zero_length_array_section:this->ptr \[bias: 0\]\) map\(from:mapped \[len: [0-9]+\]\) map\(alloc:\*_[0-9]+ \[len: 0\]\) firstprivate\(n\)} "gimple" } } */ +/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(tofrom:\*this \[len: [0-9]+\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\) map\(attach_zero_length_array_section:this->ptr \[bias: 0\]\) map\(from:mapped \[len: [0-9]+\]\) map\(alloc:MEM.* \[len: 0\]\) firstprivate\(n\)} "gimple" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/target-this-4.C b/gcc/testsuite/g++.dg/gomp/target-this-4.C index 3b2d5811350..af23cbb9023 100644 --- a/gcc/testsuite/g++.dg/gomp/target-this-4.C +++ b/gcc/testsuite/g++.dg/gomp/target-this-4.C @@ -102,6 +102,6 @@ int main (void) return 0; } -/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(to:\*__closure \[len: [0-9]+\]\) map\(firstprivate:__closure \[pointer assign, bias: 0\]\) map\(struct:\*__closure \[len: 1\]\) map\(alloc:__closure->__this \[len: [0-9]+\]\) map\(tofrom:\*_[0-9]+ \[len: [0-9]+\]\) map\(always_pointer:__closure->__this \[pointer assign, bias: 0\]\) map\(attach_zero_length_array_section:_[0-9]+->ptr \[bias: 0\]\) map\(from:mapped \[len: 1\]\) map\(alloc:\*_[0-9]+ \[len: 0\]\) firstprivate\(n\) map\(alloc:MEM.* \[len: 0\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\)} "gimple" } } */ +/* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(to:\*__closure \[len: [0-9]+\]\) map\(firstprivate:__closure \[pointer assign, bias: 0\]\) map\(struct:\*__closure \[len: 1\]\) map\(alloc:__closure->__this \[len: [0-9]+\]\) map\(tofrom:\*_[0-9]+ \[len: [0-9]+\]\) map\(always_pointer:__closure->__this \[pointer assign, bias: 0\]\) map\(attach_zero_length_array_section:_[0-9]+->ptr \[bias: 0\]\) map\(from:mapped \[len: 1\]\) map\(alloc:MEM.* \[len: 0\]\) firstprivate\(n\) map\(alloc:MEM.* \[len: 0\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\)} "gimple" } } */ /* { dg-final { scan-tree-dump {#pragma omp target num_teams.* map\(to:\*__closure \[len: [0-9]+\]\) map\(firstprivate:__closure \[pointer assign, bias: 0\]\) map\(struct:\*__closure \[len: 1\]\) map\(alloc:__closure->__this \[len: [0-9]+\]\) map\(tofrom:\*_[0-9]+ \[len: [0-9]+\]\) map\(always_pointer:__closure->__this \[pointer assign, bias: 0\]\) map\(alloc:\*_[0-9]+ \[pointer assign, zero-length array section, bias: 0\]\) map\(attach:_[0-9]+->refptr \[bias: 0\]\) map\(from:mapped \[len: [0-9]+\]\) map\(alloc:\*_[0-9]+ \[len: 0\]\) firstprivate\(n\) map\(alloc:MEM.* \[len: 0\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\)} "gimple" } } */ diff --git a/gcc/testsuite/g++.dg/gomp/target-this-5.C b/gcc/testsuite/g++.dg/gomp/target-this-5.C deleted file mode 100644 index a9ac74bcf1f..00000000000 --- a/gcc/testsuite/g++.dg/gomp/target-this-5.C +++ /dev/null @@ -1,34 +0,0 @@ -// { dg-do compile } -// { dg-additional-options "-fdump-tree-gimple" } -extern "C" void abort (); - -template -struct S -{ - T a, b, c, d; - - T sum (void) - { - T val = 0; - val += a + b + this->c + this->d; - return val; - } - - T sum_offload (void) - { - T val = 0; - #pragma omp target map(val) - val += a + b + this->c + this->d; - return val; - } -}; - -int main (void) -{ - S s = { 1, 2, 3, 4 }; - if (s.sum () != s.sum_offload ()) - abort (); - return 0; -} - -/* { dg-final { scan-tree-dump {map\(tofrom:\*this \[len: [0-9]+\]\) map\(firstprivate:this \[pointer assign, bias: 0\]\)} "gimple" } } */ diff --git a/libgomp/testsuite/libgomp.c++/target-this-5.C b/libgomp/testsuite/libgomp.c++/target-this-5.C deleted file mode 100644 index e71c566687d..00000000000 --- a/libgomp/testsuite/libgomp.c++/target-this-5.C +++ /dev/null @@ -1,30 +0,0 @@ -extern "C" void abort (); - -template -struct S -{ - T a, b, c, d; - - T sum (void) - { - T val = 0; - val += a + b + this->c + this->d; - return val; - } - - T sum_offload (void) - { - T val = 0; - #pragma omp target map(val) - val += a + b + this->c + this->d; - return val; - } -}; - -int main (void) -{ - S s = { 1, 2, 3, 4 }; - if (s.sum () != s.sum_offload ()) - abort (); - return 0; -}