<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/138102>138102</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Referring to an instruction in another function!
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          k-arrows
      </td>
    </tr>
</table>

<pre>
    Reproducible on Godbolt:
https://godbolt.org/z/44Ej9E6Gj
```f90
integer, parameter :: N = 100000, CHUNKSZ = 10000
real :: Z(N)
integer :: C, i

do C = 1, N, CHUNKSZ
    !$omp task
        !$omp target map(Z(C:C+CHUNKSZ-1))
 !$omp parallel do
            do i = C, C+CHUNKSZ-1
            end do
 !$omp end target
    !$omp end task
end do
end
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxkUsFu2zoQ_JrVhbBBkaIjHXRQ7CgPeKhbpOglN0pcyUwoUiCpFO3XF5Sd2kkJASJmd2ZnwZEh6NEi1iDuQRwyucST8_XrRnrvfoasc-pX_YSzd2rpdWeQOEseneqcicAboM0pxjmkK2uBteO5tHV-BNb-BtYWxcNL9bB7fAHawI6ev6GiQBttI47oge3JLL2cMKInSYo35EiAH0hO00kN-_9-HP___nxFgTYepXnvfwZWHoFVV9n3yj7RdZpOG-XI_iyRwOONMNCGEEKA5cAKN80kyvB6AT8X_IiRTHIGVqaxe-DNHtj9RWmTJxurkxtWWtAYNES5G9V0lCN69bQa_Sj0sROtutCvugk7O_png3Np3eIvE626fYdM1VxVvJIZ1vldsaMVo7zITnVZ9qqjw24nO8H6QVJZ3fV9eZerjvOhLDNdM8oEFTSnFeeCb8Ugq74YkCspWCEEFBQnqc3WmLcp5SHTISxY57zMKcuM7NCE99j5OnVtumUMUFCjQwxXXtTRrAFtjbQjiAOI-68z2i_fQBzIEw7ovbYjiY5IS7QN0S991C7dibQuntCTYbErBizPFm_qT7HV8bR0295NwNo0-PLbzN69YB-Btav7AKy9LPBWsz8BAAD__3Ga7eQ">