+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-10-27 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
+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-10-26 Tobias Burnus <tobias@codesourcery.com>
Backported from master:
allocator_
= gfc_trans_omp_variable (n->u2.allocator->symtree->n.sym,
false);
- if (POINTER_TYPE_P (TREE_TYPE (allocator_)))
- {
+ if (POINTER_TYPE_P (TREE_TYPE (allocator_)))
allocator_ = build_fold_indirect_ref (allocator_);
- allocator_ = gfc_evaluate_now (allocator_, block);
- }
}
else if (alloc_expr != n->u2.allocator)
{
kind = GF_OMP_ALLOCATE_KIND_ALLOCATE;
else
kind = GF_OMP_ALLOCATE_KIND_FREE;
+ for (tree c = OMP_ALLOCATE_CLAUSES (expr); c; c = OMP_CLAUSE_CHAIN (c))
+ {
+ if (OMP_CLAUSE_CODE (c) != OMP_CLAUSE_ALLOCATE)
+ continue;
+
+ gimplify_expr (&OMP_CLAUSE_ALLOCATE_ALLOCATOR (c), pre_p, NULL,
+ is_gimple_val, fb_rvalue);
+ }
+
gimple *stmt = gimple_build_omp_allocate (OMP_ALLOCATE_CLAUSES (expr),
kind);
gimplify_seq_add_stmt (pre_p, stmt);
continue;
const gcall *gs = as_a <const gcall *> (stmt);
- tree allocator = OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)
- ? OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)
- : build_zero_cst (ptr_type_node);
if (allocate)
{
+ tree allocator = (OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)
+ ? OMP_CLAUSE_ALLOCATE_ALLOCATOR (c)
+ : build_zero_cst (ptr_type_node));
tree lhs = gimple_call_lhs (gs);
if (lhs && TREE_CODE (lhs) == SSA_NAME)
{
if (arg == var)
{
tree repl = builtin_decl_explicit (BUILT_IN_GOMP_FREE);
+ tree allocator = build_zero_cst (ptr_type_node);
gimple *g = gimple_build_call (repl, 2,
gimple_call_arg (gs, 0),
allocator);
+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'
--- /dev/null
+! { 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" } }