aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog.omp5
-rw-r--r--gcc/omp-low.cc6
-rw-r--r--gcc/testsuite/ChangeLog.omp5
-rw-r--r--gcc/testsuite/c-c++-common/gomp/usm-2.c9
-rw-r--r--gcc/testsuite/c-c++-common/gomp/usm-3.c9
5 files changed, 30 insertions, 4 deletions
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index c419396..a98d8b3 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,8 @@
+2022-04-02 Andrew Stubbs <ams@codesourcery.com>
+
+ * omp-low.cc (usm_transform): Transform omp_target_alloc and
+ omp_target_free.
+
2022-03-31 Abid Qadeer <abidh@codesourcery.com>
* omp-low.cc (lower_omp_allocate): Move allocate declaration
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index 8685a0b..0734a4e 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -16143,7 +16143,8 @@ usm_transform (gimple_stmt_iterator *gsi_p, bool *,
if ((strcmp (name, "malloc") == 0)
|| (fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
&& DECL_FUNCTION_CODE (fndecl) == BUILT_IN_MALLOC)
- || DECL_IS_REPLACEABLE_OPERATOR_NEW_P (fndecl))
+ || DECL_IS_REPLACEABLE_OPERATOR_NEW_P (fndecl)
+ || strcmp (name, "omp_target_alloc") == 0)
{
tree omp_alloc_type
= build_function_type_list (ptr_type_node, size_type_node,
@@ -16215,7 +16216,8 @@ usm_transform (gimple_stmt_iterator *gsi_p, bool *,
|| (fndecl_built_in_p (fndecl, BUILT_IN_NORMAL)
&& DECL_FUNCTION_CODE (fndecl) == BUILT_IN_FREE)
|| (DECL_IS_OPERATOR_DELETE_P (fndecl)
- && DECL_IS_REPLACEABLE_OPERATOR (fndecl)))
+ && DECL_IS_REPLACEABLE_OPERATOR (fndecl))
+ || strcmp (name, "omp_target_free") == 0)
{
tree omp_free_type
= build_function_type_list (void_type_node, ptr_type_node,
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 6ff2e73..9d8026e 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,8 @@
+2022-04-02 Andrew Stubbs <ams@codesourcery.com>
+
+ * c-c++-common/gomp/usm-2.c: Add omp_target_alloc.
+ * c-c++-common/gomp/usm-3.c: Add omp_target_alloc.
+
2022-03-11 Andrew Stubbs <ams@codesourcery.com>
Backport of the patch posted at
diff --git a/gcc/testsuite/c-c++-common/gomp/usm-2.c b/gcc/testsuite/c-c++-common/gomp/usm-2.c
index 64dbb6b..8c20ef9 100644
--- a/gcc/testsuite/c-c++-common/gomp/usm-2.c
+++ b/gcc/testsuite/c-c++-common/gomp/usm-2.c
@@ -12,6 +12,8 @@ void *aligned_alloc (__SIZE_TYPE__, __SIZE_TYPE__);
void *calloc(__SIZE_TYPE__, __SIZE_TYPE__);
void *realloc(void *, __SIZE_TYPE__);
void free (void *);
+void *omp_target_alloc (__SIZE_TYPE__, int);
+void omp_target_free (void *, int);
#ifdef __cplusplus
}
@@ -24,16 +26,21 @@ foo ()
void *p2 = realloc(p1, 30);
void *p3 = calloc(4, 15);
void *p4 = aligned_alloc(16, 40);
+ void *p5 = omp_target_alloc(50, 1);
free (p2);
free (p3);
free (p4);
+ omp_target_free (p5, 1);
}
/* { dg-final { scan-tree-dump-times "omp_alloc \\(20, 10\\)" 1 "usm_transform" } } */
/* { dg-final { scan-tree-dump-times "omp_realloc \\(.*, 30, 10, 10\\)" 1 "usm_transform" } } */
/* { dg-final { scan-tree-dump-times "omp_calloc \\(4, 15, 10\\)" 1 "usm_transform" } } */
/* { dg-final { scan-tree-dump-times "omp_aligned_alloc \\(16, 40, 10\\)" 1 "usm_transform" } } */
-/* { dg-final { scan-tree-dump-times "omp_free" 3 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-times "omp_alloc \\(50, 10\\)" 1 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-times "omp_free" 4 "usm_transform" } } */
/* { dg-final { scan-tree-dump-not " free" "usm_transform" } } */
/* { dg-final { scan-tree-dump-not " aligned_alloc" "usm_transform" } } */
/* { dg-final { scan-tree-dump-not " malloc" "usm_transform" } } */
+/* { dg-final { scan-tree-dump-not " omp_target_alloc" "usm_transform" } } */
+/* { dg-final { scan-tree-dump-not " omp_target_free" "usm_transform" } } */
diff --git a/gcc/testsuite/c-c++-common/gomp/usm-3.c b/gcc/testsuite/c-c++-common/gomp/usm-3.c
index 934582e..2b0cbb4 100644
--- a/gcc/testsuite/c-c++-common/gomp/usm-3.c
+++ b/gcc/testsuite/c-c++-common/gomp/usm-3.c
@@ -10,6 +10,8 @@ void *aligned_alloc (__SIZE_TYPE__, __SIZE_TYPE__);
void *calloc(__SIZE_TYPE__, __SIZE_TYPE__);
void *realloc(void *, __SIZE_TYPE__);
void free (void *);
+void *omp_target_alloc (__SIZE_TYPE__, int);
+void omp_target_free (void *, int);
#ifdef __cplusplus
}
@@ -22,16 +24,21 @@ foo ()
void *p2 = realloc(p1, 30);
void *p3 = calloc(4, 15);
void *p4 = aligned_alloc(16, 40);
+ void *p5 = omp_target_alloc(50, 1);
free (p2);
free (p3);
free (p4);
+ omp_target_free (p5, 1);
}
/* { dg-final { scan-tree-dump-times "omp_alloc \\(20, 10\\)" 1 "usm_transform" } } */
/* { dg-final { scan-tree-dump-times "omp_realloc \\(.*, 30, 10, 10\\)" 1 "usm_transform" } } */
/* { dg-final { scan-tree-dump-times "omp_calloc \\(4, 15, 10\\)" 1 "usm_transform" } } */
/* { dg-final { scan-tree-dump-times "omp_aligned_alloc \\(16, 40, 10\\)" 1 "usm_transform" } } */
-/* { dg-final { scan-tree-dump-times "omp_free" 3 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-times "omp_alloc \\(50, 10\\)" 1 "usm_transform" } } */
+/* { dg-final { scan-tree-dump-times "omp_free" 4 "usm_transform" } } */
/* { dg-final { scan-tree-dump-not " free" "usm_transform" } } */
/* { dg-final { scan-tree-dump-not " aligned_alloc" "usm_transform" } } */
/* { dg-final { scan-tree-dump-not " malloc" "usm_transform" } } */
+/* { dg-final { scan-tree-dump-not " omp_target_alloc" "usm_transform" } } */
+/* { dg-final { scan-tree-dump-not " omp_target_free" "usm_transform" } } */