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

    <tr>
        <th>Summary</th>
        <td>
            [flang][OpenMP] Compiler crash with nowait on target construct
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          abidh
      </td>
    </tr>
</table>

<pre>
    Consider the following program.

```
program nowait_reproducer
   implicit none

   real x

   !$omp target map(tofrom: x) nowait
      x = 5
 !$omp end target

end program nowait_reproducer
```

Compiling it with the following cause the compiler to crash

`flang -fopenmp test.f90`

Note that adding --offload-arch makes the crash go away.  The call stack of the crash site looks like as follows:

```
llvm::CallInst::init
llvm::IRBuilderBase::CreateCall
llvm::OpenMPIRBuilder::emitTargetTask
llvm::OpenMPIRBuilder::finalize
mlir::LLVM::ModuleTranslation::~ModuleTranslation
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyEU02PtDYM_jXhYs0IAszHgcN8aKSVdtuqGvVaGeJAOiFBSdjZ7aG_vQqwO9uu9L5SJLDjx85jP0bvVWuIKlYeWXlOcAyddRXWSnRJbcV7dbLGK0EOQkcgrdb2rkwLg7Otw37N0kM8m3Q56WG5AWPvqMKfjgZnxdiQY-kBAFQ_aNWoAMYamtEA4Ag1vH2ajGeMF7YfIKBrKUCPA-O7YKWzPcsP8Mb4fqkwIwDgDVh-hjLaDzwZseSYk0f7Ry_8yoSlh5PtB6UjYRXgrkL3vzY0OHqafM0UGftkoXHou8_OSI2mhZW0A5nIiHxYy_2jxi82xBQYAIWISVcrK6W2KFbomg56vJGfa8S80FrAO76vAa7Rh1qDD9jcwMovUV4FAm3tzYNWNwL0y7M9yw_fp6b1a2wsyw8n1PrJ-DBbykwdflw__X4clRbkjuhpQTjCQBH3n8hfBzIvv33Gz07qVbhO87iiv_08XiqDWv0dldJrtTifn_94mf9erBg1XR0arzEoa2b3P9_9X-gmosrFPt9jQlW2zbf7fb7bFElXNTKTMitEUWxEvpXU7HhDdZE2lBeUIiaq4ikv04xvs01acL6WdSaKLS_4jqe13KSsSKlHpdeR1tq6NlHej1RlvCi3u0RjTdpPy8b5pAvGedw7V0XAqh5bz4pUKx_8I0VQQU8bOiPKMyuPc7NYeYbTh_DmuU8inZUN1nzsT2OND25sQjI6XXUhDJMM-IXxS6tCN9brxvaMX6ZxzJ_V4Oxf1ATGLxMJz_hl4fFa8X8DAAD__2-OWjc">