aboutsummaryrefslogtreecommitdiff
path: root/gcc/c-family
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2020-06-03 12:28:25 +0200
committerTobias Burnus <tobias@codesourcery.com>2020-06-03 12:30:04 +0200
commit93535a2b40367e6f68433295b37dc52c0e9c2c55 (patch)
tree3fd7c1567794717f5f0e8b88717e9106ab8748dd /gcc/c-family
parentdda71670514e88dcd9b913c44c0ee64d8c3d6da9 (diff)
downloadgcc-93535a2b40367e6f68433295b37dc52c0e9c2c55.zip
gcc-93535a2b40367e6f68433295b37dc52c0e9c2c55.tar.gz
gcc-93535a2b40367e6f68433295b37dc52c0e9c2c55.tar.bz2
[OpenMP] Fix mapping of artificial variables (PR94874)
gcc/c-family/ChangeLog: * c-common.h (c_omp_predetermined_mapping): Declare. * c-omp.c (c_omp_predetermined_mapping): New. gcc/c/ChangeLog: * c-objc-common.h (LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Redefine. gcc/cp/ChangeLog: * cp-gimplify.c (cxx_omp_predetermined_mapping): New. * cp-objcp-common.h (LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Redfine. * cp-tree.h (cxx_omp_predetermined_mapping): Declare. gcc/fortran/ChangeLog: * f95-lang.c (LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Redefine. * trans-openmp.c (gfc_omp_predetermined_mapping): New. * trans.h (gfc_omp_predetermined_mapping): Declare. gcc/ChangeLog: * gimplify.c (omp_notice_variable): Use new hook. * langhooks-def.h (lhd_omp_predetermined_mapping): Declare. (LANG_HOOKS_OMP_PREDETERMINED_MAPPING): Define (LANG_HOOKS_DECLS): Add it. * langhooks.c (lhd_omp_predetermined_sharing): Remove bogus unused attr. (lhd_omp_predetermined_mapping): New. * langhooks.h (struct lang_hooks_for_decls): Add new hook. gcc/testsuite/ChangeLog 2020-06-03 Thomas Schwinge <thomas@codesourcery.com> Tobias Burnus <tobias@codesourcery.com> PR middle-end/94874 * c-c++-common/gomp/pr94874.c: New.
Diffstat (limited to 'gcc/c-family')
-rw-r--r--gcc/c-family/c-common.h1
-rw-r--r--gcc/c-family/c-omp.c24
2 files changed, 24 insertions, 1 deletions
diff --git a/gcc/c-family/c-common.h b/gcc/c-family/c-common.h
index 7c1a637..c74b23d 100644
--- a/gcc/c-family/c-common.h
+++ b/gcc/c-family/c-common.h
@@ -1206,6 +1206,7 @@ extern tree c_omp_declare_simd_clauses_to_numbers (tree, tree);
extern void c_omp_declare_simd_clauses_to_decls (tree, tree);
extern bool c_omp_predefined_variable (tree);
extern enum omp_clause_default_kind c_omp_predetermined_sharing (tree);
+extern enum omp_clause_defaultmap_kind c_omp_predetermined_mapping (tree);
extern tree c_omp_check_context_selector (location_t, tree);
extern void c_omp_mark_declare_variant (location_t, tree, tree);
extern const char *c_omp_map_clause_name (tree, bool);
diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index 51c18a4..6f8fba3 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -2104,7 +2104,8 @@ c_omp_predefined_variable (tree decl)
return false;
}
-/* True if OpenMP sharing attribute of DECL is predetermined. */
+/* OMP_CLAUSE_DEFAULT_UNSPECIFIED unless OpenMP sharing attribute of DECL
+ is predetermined. */
enum omp_clause_default_kind
c_omp_predetermined_sharing (tree decl)
@@ -2123,6 +2124,27 @@ c_omp_predetermined_sharing (tree decl)
return OMP_CLAUSE_DEFAULT_UNSPECIFIED;
}
+/* OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED unless OpenMP mapping attribute
+ of DECL is predetermined. */
+
+enum omp_clause_defaultmap_kind
+c_omp_predetermined_mapping (tree decl)
+{
+ /* Predetermine artificial variables holding integral values, those
+ are usually result of gimplify_one_sizepos or SAVE_EXPR
+ gimplification. */
+ if (VAR_P (decl)
+ && DECL_ARTIFICIAL (decl)
+ && INTEGRAL_TYPE_P (TREE_TYPE (decl)))
+ return OMP_CLAUSE_DEFAULTMAP_FIRSTPRIVATE;
+
+ if (c_omp_predefined_variable (decl))
+ return OMP_CLAUSE_DEFAULTMAP_TO;
+
+ return OMP_CLAUSE_DEFAULTMAP_CATEGORY_UNSPECIFIED;
+}
+
+
/* Diagnose errors in an OpenMP context selector, return CTX if
it is correct or error_mark_node otherwise. */