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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] wrong result with BLOCK in target region
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          ye-luo
      </td>
    </tr>
</table>

<pre>
    I tested AMD downstream compiler and realized that the issue was from upstream.
flang version 20.0.0git (https://github.com/llvm/llvm-project.git 5a5502b9e1ca04626f7fd03c581b6deb5cd39c13)

Got wrong results regardless of enabling offload or not.

Code https://github.com/ye-luo/openmp-target/blob/master/tests/private/target_local_block.f90
```
yeluo@epyc-server:~/opt/openmp-target/tests/private$ flang -fopenmp --offload-arch=gfx906 target_local_block.f90 && ./a.out
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
 collect_a expected 20, now =  10
Fortran STOP: code 1

IEEE arithmetic exceptions signaled: INEXACT
yeluo@epyc-server:~/opt/openmp-target/tests/private$ flang -fopenmp target_local_block.f90 && ./a.out
flang-20: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
 collect_a expected 20, now =  10
Fortran STOP: code 1
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzcVF2L4zYU_TXyy8VGkj8SP_ghMxmXod3OQhfat0GWr2y1smQkOZnpQ397sZ2lKV0KhRbKQohtoatzdc65R4SgB4vYkPKBlOdELHF0vnnH1Cwu6Vz_3jxDxBCxh9OHM_TuakP0KCaQbpq1QQ_C9uBRGP0r9hBHESGOCDqEBeEqAijvJljmvSwj9EzoSRlhB7igD9pZ4DSjGR10BMKPY4xzIPmJ8JbwdtBxXLpMuonw1pjL50c6e_czypitVaUoS8q7GpkUtKh4pQ6qp7ksj6yreuxK2ee1ZDnh9Q6__3_jIly9swN4DIuJATwOwvcGQwCnAK3ojLYDOKWMEz04D9bF7P6MR9cj_E3LO5OEt25GO81pFH7ASHjbGdcR3k4iRPSEtyvJgfB29voiIq4r29ZX46Qwr51x8pdM1fQGXtHbb_t8xxWkoDi_yzSgv6An-em3DTZ-AfwvYAXsiqRq3wppert0KrwcSX4e1FtNK_hyU0B4RXgFGeGtyNwS71ROOSX5Ca7CW22H9fVlRvvhI4Rlnp2PoO0NXAcIURsD-Daj1xPaKAyQ8iH98X4ldXPUzpLy_PWhgHTGoIyvYiuU69xxSvgjWHcFkp8B2E3z1vnohYUfPr18XDuRqxPZvTefn56eQHgdxwmjloBvEje4AOvUC4P9Wvj8_dNPp8dP_5WT_oeO-bdY_jyESd_kfZ3XIsGGHXJ2qFlBq2RscnromCo6xnJR0oJ2nNXyqBTnXB5FxxLdcMoLxljFGaO0ymQhZIWo1FFV6lCzVYpJaJOtoZc5PyRbsDaMVSWtEyM6NGFLb843Tgjna5D7ZkvJbhkCKajRIYY_jog6mi3y262iPJPyYaeYlOc_RSJcdRzh4buXx29X1nct15jUziaLN80_S2vC26391TG3G1wa_nsAAAD__0auHw8">