This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[committed] Fix handling of DECL_IN_CONSTANT_POOL in OpenMP gimplification (PR middle-end/91920)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 27 Sep 2019 22:16:50 +0200
- Subject: [committed] Fix handling of DECL_IN_CONSTANT_POOL in OpenMP gimplification (PR middle-end/91920)
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
Hi!
The DECL_IN_CONSTANT_POOL variables are artificial vars that need to be
predetermined shared, they aren't user visible and user has no control about
those. In C/C++, we predetermine artificial variables shared, but only if
they have integral types.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux,
committed to trunk, queued for backporting.
2019-09-27 Jakub Jelinek <jakub@redhat.com>
PR middle-end/91920
* gimplify.c (omp_default_clause): Predetermine DECL_IN_CONSTANT_POOL
variables as shared.
* c-c++-common/gomp/pr91920.c: New test.
--- gcc/gimplify.c.jj 2019-09-20 12:25:46.829408105 +0200
+++ gcc/gimplify.c 2019-09-27 11:52:17.458446652 +0200
@@ -7132,6 +7132,8 @@ omp_default_clause (struct gimplify_omp_
kind = lang_hooks.decls.omp_predetermined_sharing (decl);
if (kind != OMP_CLAUSE_DEFAULT_UNSPECIFIED)
default_kind = kind;
+ else if (VAR_P (decl) && TREE_STATIC (decl) && DECL_IN_CONSTANT_POOL (decl))
+ default_kind = OMP_CLAUSE_DEFAULT_SHARED;
switch (default_kind)
{
--- gcc/testsuite/c-c++-common/gomp/pr91920.c.jj 2019-09-27 11:57:26.066813061 +0200
+++ gcc/testsuite/c-c++-common/gomp/pr91920.c 2019-09-27 11:57:08.931070237 +0200
@@ -0,0 +1,19 @@
+/* PR middle-end/91920 */
+
+void bar (float *);
+
+void
+foo (void)
+{
+ int i;
+ float f[3] = { 0.0f, 0.0f, 0.0f };
+#pragma omp parallel for default(none) reduction(+:f[:3])
+ for (i = 0; i < 1000; i++)
+ {
+ int j;
+ float k[3] = { 0.25f, 0.5f, 0.75f };
+ for (j = 0; j < 3; j++)
+ f[j] += k[j];
+ }
+ bar (f);
+}
Jakub