[gcc/devel/omp/gcc-14] OpenMP/Fortran: Ensure allocator is gimplified for 'omp allocate'
Paul-Antoine Arras
parras@gcc.gnu.org
Fri Jun 28 09:55:29 GMT 2024
https://gcc.gnu.org/g:728e95f82cea89a1c5636d639288b924a077508a
commit 728e95f82cea89a1c5636d639288b924a077508a
Author: Tobias Burnus <tobias@codesourcery.com>
Date: Mon Oct 30 10:53:29 2023 +0100
OpenMP/Fortran: Ensure allocator is gimplified for 'omp allocate'
Without this change, we we get an ICE in verify_gimple_call for
GOMP_allocate when doing a late replacement in omp-low.cc
gcc/fortran/ChangeLog:
* trans-openmp.cc (gfc_trans_omp_clauses): Avoid gfc_evaluate_now
for allocator with indirect ref for better diagnostic.
gcc/ChangeLog:
* gcc/gimplify.cc (gimplify_omp_allocate): Gimplify allocator.
* omp-low.cc (lower_omp_allocate): Simplify; GOMP_free can also
take a plain 0 as allocator argument (arg is unused in libgomp).
libgomp/ChangeLog:
* testsuite/libgomp.fortran/allocate-8a.f90: New test.
Diff:
---
gcc/ChangeLog.omp | 6 +++
gcc/fortran/ChangeLog.omp | 5 +++
libgomp/ChangeLog.omp | 4 ++
libgomp/testsuite/libgomp.fortran/allocate-8a.f90 | 45 +++++++++++++++++++++++
4 files changed, 60 insertions(+)
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index 71b160a3941..2dc54be77f6 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,9 @@
+2023-10-30 Tobias Burnus <tobias@codesourcery.com>
+
+ * gcc/gimplify.cc (gimplify_omp_allocate): Gimplify allocator.
+ * omp-low.cc (lower_omp_allocate): Simplify; GOMP_free can also
+ take a plain 0 as allocator argument (arg is unused in libgomp).
+
2023-07-14 Julian Brown <julian@codesourcery.com>
* omp-low.cc (lower_omp_target): Reverse iteration over array
diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 9dbfd33eab4..85f76fc0120 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,8 @@
+2023-10-30 Tobias Burnus <tobias@codesourcery.com>
+
+ * trans-openmp.cc (gfc_trans_omp_clauses): Avoid gfc_evaluate_now
+ for allocator with indirect ref for better diagnostic.
+
2023-07-14 Julian Brown <julian@codesourcery.com>
* trans-openmp.cc (gfc_trans_omp_arrayshape_type): Reverse dimension
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 090341800b5..fad929553cf 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,7 @@
+2023-10-30 Tobias Burnus <tobias@codesourcery.com>
+
+ * testsuite/libgomp.fortran/allocate-8a.f90: New test.
+
2023-10-26 Tobias Burnus <tobias@codesourcery.com>
* libgomp.texi (OpenMP Impl. Status): Document that 'omp allocate'
diff --git a/libgomp/testsuite/libgomp.fortran/allocate-8a.f90 b/libgomp/testsuite/libgomp.fortran/allocate-8a.f90
new file mode 100644
index 00000000000..5f6c8c1e271
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/allocate-8a.f90
@@ -0,0 +1,45 @@
+! { dg-additional-options "-fopenmp-allocators" }
+! { dg-additional-options "-fdump-tree-omplower" }
+program main
+ use iso_c_binding
+ use omp_lib
+ implicit none (type, external)
+ integer(omp_allocator_handle_kind):: alloc_h
+ integer :: i, N
+ integer(c_intptr_t) :: intptr
+ integer, allocatable :: A(:)
+ type(omp_alloctrait):: traits(1) = [omp_alloctrait(omp_atk_alignment, 128)]
+
+ N = 10
+ alloc_h = omp_init_allocator(omp_default_mem_space, 1, traits)
+
+ !$omp allocate(A) allocator(alloc_h)
+ allocate(A(N))
+ a(:) = [(i, i=1,N)]
+ if (mod (transfer (loc(a), intptr),128) /= 0) &
+ stop 1
+ if (any (a /= [(i, i=1,N)])) &
+ stop 2
+ deallocate(A)
+ !$omp allocate(A) allocator(alloc_h) align(512)
+ allocate(A(N))
+ block
+ integer, allocatable :: B(:)
+ !$omp allocators allocate(allocator(alloc_h), align(256) : B)
+ allocate(B(N))
+ B(:) = [(2*i, i=1,N)]
+ A(:) = B
+ if (mod (transfer (loc(B), intptr), 256) /= 0) &
+ stop 1
+ ! end of scope deallocation
+ end block
+ if (mod (transfer (loc(a), intptr),512) /= 0) &
+ stop 1
+ if (any (a /= [(2*i, i=1,N)])) &
+ stop 2
+ deallocate(A) ! Must deallocate here - before deallocator is destroyed
+ call omp_destroy_allocator(alloc_h)
+ ! No auto dealloc of A because it is SAVE
+end
+! { dg-final { scan-tree-dump-times "__builtin_GOMP_alloc \\(" 3 "omplower" } }
+! { dg-final { scan-tree-dump-times "__builtin_GOMP_free \\(" 3 "omplower" } }
More information about the Gcc-cvs
mailing list