<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/112884>112884</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[flang][OpenMP] crash in OpenMPIRBuilder when trying to outline a parallel region with an infinite loop
</td>
</tr>
<tr>
<th>Labels</th>
<td>
crash-on-valid,
flang:openmp,
llvm:openmpirbuilder
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
tblah
</td>
</tr>
</table>
<pre>
```
program infinite_loop
integer :: i
!$omp parallel
do
i = 0
end do
!$omp end parallel
end program
```
This crashes in `llvm::CodeExtractor::findAllocas` called from `llvm::OpenMPIRBuilder::createParallel`. My guess is that the code extractor is looking for live out-values from the CFG region but gets stuck at the infinite loop.
Surprisingly equivalent C code does not crash clang.
Reproduce with `flang -fopenmp file.f90`
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxcU81u2zwQfBrqsrBBUbJiHXRw7M8feggapL0XlLiStqFJlaSc-u0L6ieJAxiWMKvdHc4MpffUGcSK7R7Z7pTIMfTWVaHWsk9qq24VK_jy4yfGD4OznZMXINOSoYC_tLXDXAIgE7BDByw7sOwAtOJMpEzk9jLAIJ3UGvVaUXZ9AyBg2QmWPYBGfap-TIj4_ZQJmWnNwBfK8__Pnjw0TvoePZABVnCtr5eZ6tEq_O9vcLIJ1s1QS0YdtLaN9Kzg0MSFClpnL_et3wc0T8_fXh5H0gqX5sahDPi80iz4Fp5u0I3oPZCH0MsAoUdorELAdXEsaWtfyXTQWgeargh2DJur1CP6eXlsO57_B4cdWQP1GKDD4MGHsXmFZe7qThw3bD_L8GN0gyNPptM3wD8jXaVGE-A4c1EWPRgbZqWg0dJ0d_0vODirxgbhjUIfpWjjN7Bp7YDmMkBLGrdtGeVPVJWpMitlglX6IEqxSwuRJ31VYsPFrlB1xrOy5Q8pb2rO21oUqVIqKxOqBBd5ytN9muZciG1a8Az3eVGXdZlJ-cByjhdJehuN2FrXJeT9iFWaiv0-T7SsUfsp1EJMR9lYE2UkxYRg4siEmHiz7DDzfocXZ2eUXL3YKkS8Hq6K5U09dp7lXJMP_oNBoKCnizRP3p3Y7nFOB9udFkHJwJfAwFuPBoK7RdeDjX5rMgjyPeWr1ZPg0tybm4xOV30Ig4_JE2cmzh2Ffqy3jb0wcZ6OMz82g7O_sQlMnCexPBPnRa9rJf4FAAD__yDmSK4">