<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/156466>156466</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][OpenMP] Omitting optional mapper-identifier in declare mapper breaks data mapping
</td>
</tr>
<tr>
<th>Labels</th>
<td>
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jfuchs-kmt
</td>
</tr>
</table>
<pre>
I am using the most recent `flang version 22.0.0git (git@github.com:llvm/llvm-project.git 89f53af3fffed3e41167fbb7bc10d4885cd97c7f)`.
The snippet below shows that when omitting the optional mapper-identifier (`custom` in this case), then `real_arr` is not mapped properly from and/or to the device.
```fortran
! flang -O2 -fopenmp -fopenmp-version=52 -fopenmp-targets=nvptx64-nvidia-cuda main.F90 -D_IDENTIFIER_
PROGRAM reproducer
IMPLICIT NONE
TYPE :: real_t
REAL, ALLOCATABLE :: real_arr(:)
END TYPE real_t
#ifdef _IDENTIFIER_
!$omp declare mapper(custom: real_t :: t) map(tofrom: t%real_arr)
#else
!$omp declare mapper(real_t :: t) map(tofrom: t%real_arr)
#endif
TYPE(real_t) :: r
ALLOCATE(r%real_arr(10), source=1.0)
PRINT*, "BEFORE TARGET REGION:"
PRINT*, "real_arr: ", r%real_arr
PRINT*, ""
!$omp target map(tofrom: r)
r%real_arr = 3.0
!$omp end target
PRINT*, "AFTER TARGET REGION:"
PRINT*, "real_arr: ", r%real_arr
DEALLOCATE(r%real_arr)
END PROGRAM reproducer
```
1. Compiling the program with `-D_IDENTIFIER_` gives the expected result where `real_arr` contains the values `3.0` after the target region since it is being written to there and mapped back to the host
2. Compiling without the flag gives the bad behavior, where `real_arr` contains the values `1.0` after the target region. Thus the data mapping is not performed properly
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJysVV1vozoQ_TXOyyjImI-EhzzQhqwitUkV5eU-VQYG8BZsZJt0999fGUj6sd29ulcXVWrwzJyZOY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