<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/60737>60737</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Flang][OpenMP] Lower Stop statements in OpenMP regions
</td>
</tr>
<tr>
<th>Labels</th>
<td>
openmp,
flang:ir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kiranchandramohan
</td>
</tr>
</table>
<pre>
OpenMP standard for Fortran permits `STOP` statements in parallel regions. Currently code with `STOP` statements are not lowered correctly. There could be a few issues here,
1. Flang lowering inserts `fir.unreachable` which is a terminator. It is possible that this is not recognised as a terminator for OpenMP regions.
2. Typically OpenMP lowering code inserts the terminator, and might still insert an `omp.terminator` or `omp.yield` eventhough a `fir.unreachable` is present.
3. Translation code from MLIR using OpenMPIRBuilder will not handle `llvm.unreachable` if it is the region terminator for OpenMP.
**Reproducer**
```
program mn
!$omp parallel
stop 1
!$omp end parallel
end program
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx0VO2OnDgQfBrzpxUE5mNufvBjd0cjrZQo0WZfoMEN9p2xUdtkNG9_MrB72VwiWSC3291VRRcYgpkcUSeaR9FcMlyj9tz9YxjdoNEpxtlrdFnv1b37upD78g1CRKeQFYye4eo5MjpYiGcTA4i2-P769Ztoi5QXaSYXAxgHCzJaSxaYJuNdyOFpZSYX7R0GrwhuJuo_XEcmcD6C9TdiUjB4ZhqivefwqokJBr9aBT0Bwkg3MCGsFCAdCfkkiosoHsocrhbdtBcxbgLjAvEOeTScr44JB429pdT-ps2gwQRAiImbw-g5h-eYYosPwfSWIGqMELUJKZogMg1-ciaQAvx4d5PrkPBNgx2azOH1vpgBrb2_Zbyj3LR5gxo1_VRRyCdAp2A2k44QorH2yAR0iZafl_yn9LYAz2_xuyGrUgjoB7mo_TppwD-IkSgzBXLxgFzl8MrogsVovNtBjuxn-PL5-QXWkJDvTJ5fHldjFTHcEr6kURosS6mVtT_m__UawWwiJ7K7UL9X8YByPGVaL7SwV-tAvO-Ps7Y41rZd2E-MM8xu3wOAkKWQtZ-X9zF9PwKAEP0C5W-SyalfLmyRvf4vvTPVVepcnTGjrmxPbXUqm-ac6a5CxHao-7bqm7HCoezP46kc62YYKqrlKTOdLGRVyLIui7ppzjn-dZZqrLHtsarrshZ1QTMam29yep6yzQBdW5yqU2axJxs2h0vpF3LzIqRMvpByTI4Q1YPhFGouGXepxqd-nYKoC2tCDP9VjSba7VexGUk0F9E87p9CNBf4nCYWvietPjr_48xnK9tOx7gEUT0IeRXyOpmo1z4f_CzkNXU7Xp8W9n_TEIW87o4W8rpx-jcAAP__FGiMfw">