int r; void foo (int *a) { int i; #pragma omp for reduction(+:r) for (i = 0; i < 64; i++) a[i] = i; #pragma omp for private (r) for (i = 0; i < 64; i++) { r = 0; #pragma omp parallel shared(r) #pragma omp master r = r + 1; } } ICEs with -fopenmp starting with r265930, most likely due to the be passing an address in this case? Should we simply assert this to be false, or should we have a cleanup pass that removes these from the list of mappings? */ - if (TREE_STATIC (decl) || DECL_EXTERNAL (decl)) + if (is_global_var (maybe_lookup_decl_in_outer_ctx (decl, shared_ctx))) return true; /* For variables with DECL_HAS_VALUE_EXPR_P set, we cannot tell omp-low.c hunk. r is a global decl, initially not TREE_ADDRESSABLE and turned into TREE_ADDRESSABLE during the reduction handling of the first worksharing loop, which means that the scaning of the parallel clauses and later lowering disagree on whether shared(r) is passed by reference or through copy-in/out.
Author: jakub Date: Tue Jul 30 07:28:22 2019 New Revision: 273898 URL: https://gcc.gnu.org/viewcvs?rev=273898&root=gcc&view=rev Log: PR middle-end/91216 * omp-low.c (global_nonaddressable_vars): New variable. (use_pointer_for_field): For global decls, if they are non-addressable, remember it in the global_nonaddressable_vars bitmap, if they are addressable and in the global_nonaddressable_vars bitmap, ignore their TREE_ADDRESSABLE bit. (omp_copy_decl_2): Clear TREE_ADDRESSABLE also on private copies of vars in global_nonaddressable_vars bitmap. (execute_lower_omp): Free global_nonaddressable_vars bitmap. * gcc.dg/gomp/pr91216.c: New test. Added: trunk/gcc/testsuite/gcc.dg/gomp/pr91216.c Modified: trunk/gcc/ChangeLog trunk/gcc/omp-low.c trunk/gcc/testsuite/ChangeLog
Author: jakub Date: Thu Aug 1 06:30:26 2019 New Revision: 273965 URL: https://gcc.gnu.org/viewcvs?rev=273965&root=gcc&view=rev Log: Backported from mainline 2019-07-30 Jakub Jelinek <jakub@redhat.com> PR middle-end/91216 * omp-low.c (global_nonaddressable_vars): New variable. (use_pointer_for_field): For global decls, if they are non-addressable, remember it in the global_nonaddressable_vars bitmap, if they are addressable and in the global_nonaddressable_vars bitmap, ignore their TREE_ADDRESSABLE bit. (omp_copy_decl_2): Clear TREE_ADDRESSABLE also on private copies of vars in global_nonaddressable_vars bitmap. (execute_lower_omp): Free global_nonaddressable_vars bitmap. * gcc.dg/gomp/pr91216.c: New test. Added: branches/gcc-9-branch/gcc/testsuite/gcc.dg/gomp/pr91216.c Modified: branches/gcc-9-branch/gcc/ChangeLog branches/gcc-9-branch/gcc/omp-low.c branches/gcc-9-branch/gcc/testsuite/ChangeLog
Fixed.