Files
llvm-project/offload/test/offloading/fortran/recursive-default-mapper.f90
Akash Banerjee 7c07cb6542 [MLIR][OpenMP] Fix recursive mapper emission. (#178453)
Recursive types can cause re-entrant mapper emission. The mapper
function is created by OpenMPIRBuilder before the callbacks run, so it
may already exist in the LLVM module even though it is not yet
registered in the ModuleTranslation mapping table. Reuse and register it
to break the recursion. Added offloading test.
2026-01-29 16:38:33 +00:00

41 lines
704 B
Fortran

! Offloading test for recursive default mapper emission
! REQUIRES: flang, amdgpu
! RUN: %libomptarget-compile-fortran-run-and-check-generic
module recursive_mapper_mod
implicit none
type :: inner
integer :: value
type(inner), pointer :: next
end type inner
type :: outer
integer, allocatable :: arr(:)
type(inner), pointer :: head
end type outer
contains
end module recursive_mapper_mod
program main
use recursive_mapper_mod
implicit none
type(outer) :: o
allocate(o%arr(2))
o%arr = [1, 2]
!$omp target map(tofrom: o)
o%arr(1) = o%arr(1) + 1
o%arr(2) = o%arr(2) + 1
!$omp end target
print *, o%arr(1), o%arr(2)
end program main
! CHECK: 2 3