aboutsummaryrefslogtreecommitdiff
path: root/gcc/omp-general.c
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2020-05-26 09:35:21 +0200
committerJakub Jelinek <jakub@redhat.com>2020-05-26 09:35:21 +0200
commitf1f862aec2c3b93dbd6adfc35b0e1b6034e59c21 (patch)
tree17585550346141aee0230a55878d86d63504b279 /gcc/omp-general.c
parent1c7f8cbcc7f77d6956624f2bb455c33f253524fd (diff)
downloadgcc-f1f862aec2c3b93dbd6adfc35b0e1b6034e59c21.zip
gcc-f1f862aec2c3b93dbd6adfc35b0e1b6034e59c21.tar.gz
gcc-f1f862aec2c3b93dbd6adfc35b0e1b6034e59c21.tar.bz2
openmp: Ensure copy ctor for composite distribute parallel for class iterators is instantiated [PR95197]
During gimplification omp_finish_clause langhook is called in several places to add the language specific info to the clause like what default/copy ctors, dtors and assignment operators should be used. Unfortunately, if it refers to some not yet instantiated method, during gimplification it is too late and the methods will not be instantiated anymore. For other cases, the genericizer has code to detect those and instantiate whatever is needed, this change adds the same for distribute parallel for class iterators where we under the hood need a copy constructor for the iterator to implement it. 2020-05-26 Jakub Jelinek <jakub@redhat.com> PR c++/95197 * gimplify.c (find_combined_omp_for): Move to omp-general.c. * omp-general.h (find_combined_omp_for): Declare. * omp-general.c: Include tree-iterator.h. (find_combined_omp_for): New function, moved from gimplify.c. * cp-gimplify.c: Include omp-general.h. (cp_genericize_r) <case OMP_DISTRIBUTE>: For class iteration variables in composite distribute parallel for, instantiate copy ctor of their types.
Diffstat (limited to 'gcc/omp-general.c')
-rw-r--r--gcc/omp-general.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/gcc/omp-general.c b/gcc/omp-general.c
index 315f24a..1a2e71e 100644
--- a/gcc/omp-general.c
+++ b/gcc/omp-general.c
@@ -42,6 +42,7 @@ along with GCC; see the file COPYING3. If not see
#include "hsa-common.h"
#include "tree-pass.h"
#include "omp-device-properties.h"
+#include "tree-iterator.h"
enum omp_requires omp_requires_mask;
@@ -504,6 +505,61 @@ omp_build_barrier (tree lhs)
return g;
}
+/* Find OMP_FOR resp. OMP_SIMD with non-NULL OMP_FOR_INIT. Also, fill in pdata
+ array, pdata[0] non-NULL if there is anything non-trivial in between,
+ pdata[1] is address of OMP_PARALLEL in between if any, pdata[2] is address
+ of OMP_FOR in between if any and pdata[3] is address of the inner
+ OMP_FOR/OMP_SIMD. */
+
+tree
+find_combined_omp_for (tree *tp, int *walk_subtrees, void *data)
+{
+ tree **pdata = (tree **) data;
+ *walk_subtrees = 0;
+ switch (TREE_CODE (*tp))
+ {
+ case OMP_FOR:
+ if (OMP_FOR_INIT (*tp) != NULL_TREE)
+ {
+ pdata[3] = tp;
+ return *tp;
+ }
+ pdata[2] = tp;
+ *walk_subtrees = 1;
+ break;
+ case OMP_SIMD:
+ if (OMP_FOR_INIT (*tp) != NULL_TREE)
+ {
+ pdata[3] = tp;
+ return *tp;
+ }
+ break;
+ case BIND_EXPR:
+ if (BIND_EXPR_VARS (*tp)
+ || (BIND_EXPR_BLOCK (*tp)
+ && BLOCK_VARS (BIND_EXPR_BLOCK (*tp))))
+ pdata[0] = tp;
+ *walk_subtrees = 1;
+ break;
+ case STATEMENT_LIST:
+ if (!tsi_one_before_end_p (tsi_start (*tp)))
+ pdata[0] = tp;
+ *walk_subtrees = 1;
+ break;
+ case TRY_FINALLY_EXPR:
+ pdata[0] = tp;
+ *walk_subtrees = 1;
+ break;
+ case OMP_PARALLEL:
+ pdata[1] = tp;
+ *walk_subtrees = 1;
+ break;
+ default:
+ break;
+ }
+ return NULL_TREE;
+}
+
/* Return maximum possible vectorization factor for the target. */
poly_uint64