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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Compilation error when type complex is used with expression-stmt in atomic construct
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          ohno-fj
      </td>
    </tr>
</table>

<pre>
    ```
Version of flang-new : 19.0.0(dd7386d85f11cf6ad911b9827c7018fb08c6c205)/AArch64
```

If type `complex` is used with `expression-stmt` in `atomic` construct, the compilation terminates abnormally.
If type `complex` is changed to type `real` or `integer`, the compilation terminates normally.

The following are the test program, Flang-new, Gfortran and ifort compilation result.

omp_PARALLEL_001c_21.f90:
```fortran
      program main
      complex(kind=8)::ca
      ca = (0.0,0.0)
!$omp parallel
!$omp atomic
      ca = ca + (1.0,0.0)
!$omp end parallel
      write(6,*) "pass"
      end
```

```
$ flang-new -fopenmp omp_PARALLEL_001c_21.f90
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/fomp_complex/omp_PARALLEL_001c_21.f90":3:7): no atomic update operation with region argument as operand found inside atomic.update region
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/fomp_complex/omp_PARALLEL_001c_21.f90":3:7): LLVM Translation failed for operation: omp.atomic.update
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /lustre/home/ohno/LLVM_20240219/release/bin/flang-new -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +outline-atomics -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/omp_PARALLEL_001c_21-1219a1.o -x f95-cpp-input omp_PARALLEL_001c_21.f90
 #0 0x00000000040220b0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x40220b0)
 #1 0x000000000401ffb8 llvm::sys::RunSignalHandlers() (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x401ffb8)
 #2 0x000000000402013c SignalHandler(int) Signals.cpp:0:0
 #3 0x00004000240a07a0 (linux-vdso.so.1+0x7a0)
 #4 0x0000000007362a0c llvm::CodeExtractor::findAllocas(llvm::CodeExtractorAnalysisCache const&, llvm::SetVector<llvm::Value*, llvm::SmallVector<llvm::Value*, 0u>, llvm::DenseSet<llvm::Value*, llvm::DenseMapInfo<llvm::Value*, void>>, 0u>&, llvm::SetVector<llvm::Value*, llvm::SmallVector<llvm::Value*, 0u>, llvm::DenseSet<llvm::Value*, llvm::DenseMapInfo<llvm::Value*, void>>, 0u>&, llvm::BasicBlock*&) const (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x7362a0c)
 #5 0x0000000006f86a78 llvm::OpenMPIRBuilder::createParallel(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::IRBuilderBase::InsertPoint, llvm::function_ref<void (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)>, llvm::function_ref<llvm::IRBuilderBase::InsertPoint (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint, llvm::Value&, llvm::Value&, llvm::Value*&)>, std::function<void (llvm::IRBuilderBase::InsertPoint)>, llvm::Value*, llvm::Value*, llvm::omp::ProcBindKind, bool) (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x6f86a78)
 #6 0x00000000056ba024 (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const OpenMPToLLVMIRTranslation.cpp:0:0
 #7 0x0000000005d43f18 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x5d43f18)
 #8 0x0000000005d4ca5c mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x5d4ca5c)
 #9 0x0000000005d4d708 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x5d4d708)
#10 0x0000000005d4e0d8 mlir::LLVM::ModuleTranslation::convertFunctions() (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x5d4e0d8)
#11 0x0000000005d5249c mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef) (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x5d5249c)
#12 0x000000000466ae80 Fortran::frontend::CodeGenAction::generateLLVMIR() (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x466ae80)
#13 0x000000000466d038 Fortran::frontend::CodeGenAction::executeAction() (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x466d038)
#14 0x000000000405706c Fortran::frontend::FrontendAction::execute() (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x405706c)
#15 0x000000000404b8dc Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x404b8dc)
#16 0x000000000405bce8 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x405bce8)
#17 0x0000000003c6b3d0 fc1_main(llvm::ArrayRef<char const*>, char const*) (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x3c6b3d0)
#18 0x0000000003bf3f70 main (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x3bf3f70)
#19 0x0000400024534384 __libc_start_main (/lib64/libc.so.6+0x24384)
#20 0x0000000003c6a24c _start (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x3c6a24c)
flang-new: error: unable to execute command: Segmentation fault (core dumped)
flang-new: error: flang frontend command failed due to signal (use -v to see invocation)
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git dd7386d85f11cf6ad911b9827c7018fb08c6c205)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /lustre/home/ohno/LLVM_20240219/release/bin
flang-new: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-new: note: diagnostic msg: /tmp/omp_PARALLEL_001c_21-1c710e
flang-new: note: diagnostic msg: /tmp/omp_PARALLEL_001c_21-1c710e.sh
flang-new: note: diagnostic msg:

********************
$
```

```
$ cat /tmp/omp_PARALLEL_001c_21-1c710e
#line "./omp_PARALLEL_001c_21.f90" 1
      program main
      complex(kind=8)::ca
      ca = (0.0,0.0)
!$omp parallel
!$omp atomic
      ca = ca + (1.0,0.0)
!$omp end parallel
      write(6,*) "pass"
 end
$
```

```
$ cat /tmp/omp_PARALLEL_001c_21-1c710e.sh
# Crash reproducer for clang version 19.0.0git (https://github.com/llvm/llvm-project.git dd7386d85f11cf6ad911b9827c7018fb08c6c205)
# Driver args: "-fopenmp" "-L/lustre/home/ohno/LLVM_20240219/release/lib" "omp_PARALLEL_001c_21.f90"
# Original command: "/lustre/home/ohno/LLVM_20240219/release/bin/flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" "-emit-obj" "-fopenmp" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "generic" "-target-feature" "+outline-atomics" "-target-feature" "+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-mframe-pointer=non-leaf" "-o" "/tmp/omp_PARALLEL_001c_21-1219a1.o" "-x" "f95-cpp-input" "omp_PARALLEL_001c_21.f90"
 "/lustre/home/ohno/LLVM_20240219/release/bin/flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" "-emit-obj" "-fopenmp" "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" "-target-cpu" "generic" "-target-feature" "+outline-atomics" "-target-feature" "+v8a" "-target-feature" "+fp-armv8" "-target-feature" "+neon" "-mframe-pointer=non-leaf" "-x" "f95-cpp-input" "omp_PARALLEL_001c_21-1c710e"
$
```

```
$ gfortran -fopenmp omp_PARALLEL_001c_21.f90
$
```

```
$ ifort -qopenmp -diag-disable=10448 omp_PARALLEL_001c_21.f90
$
```

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl9zozgS_zTKiwqXENjGD3lw7Hg2d5lLKpObe0zJorG1AxIniSTz7a8khA3O_6yn9upupzIJiKb7138l1GLGiI0EOEXjMzRenrDGbpU-VVupouL3k7XKf56iCQk_ZInI_DtoI5TEqsBFyeQmkvCAUTLH8WxERgTRLM-nSTbJs3ERx7yYsHwWx-tZRqd8SuKsWJOMTzglY0RniK7mc823k7RlfiCr_X1RYPuzBowmhKuqLuERTQgWBjcGcvwg7NY9gsdag3HQImMr60mke8CsqgR391xJY3XDLaILbLeAHTtRMuv0saArIZkFg9laKl2xsvw5egMB3zK5gRxbtSPQwEr3VGl3J6SFDWin0esyDyS2v2-3gAtVlupByA1mGjwHC8biWquNZpXjuurc4G6-FEpbzSRmMsfC3QwkajBNaQdCVFXfXc9v5peX55d3hMT8jsajYkZQMj9wSmDdjmL_L8DAFROD8c5MNPshZI6SZea8ncxRMudsQMgwSpYY0cwHz8L_ngXBNEY0VVWNa6ZZWUJ5OB58-5Sf-0PPHNv4FbYg8wPWLZMHLSwgmk0QXSA6R3SGEaU1MwZR2icEmb8SuIeDNO2lTFSoGmRV4xft718CrZV26VUqjmjm5NPVg9I_EF1tVQWIrly2Irpa3CK6crGB6Mp5yt3ViK401FrlDQf9N_-kqu923lm9KJxSlMwTlMynreOwVMHauKlzZgGrGnQbVD4FNWzcNdObpgJpMTMthcxxoRoXjNKIHAKTUWDSv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