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

    <tr>
        <th>Summary</th>
        <td>
            [Flang][OpenMP] Compilation error of `atomic capture` for complex variable
        </td>
    </tr>

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

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

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

<pre>
    This is an issue from Fujitsu testsuite.

Flang-new terminates abnormally when compiling `atomic capture` for complex variable.

The following are the test program and the compilation results of Flang-new and gfortran.

```fortran
! test.f90
module m1
contains
subroutine s1(x,v,e)
complex x,v,e
!$omp atomic capture
v=x
x=-e
!$omp end atomic
end subroutine
end

use m1
complex x,v,e
x=1
v=2
e=3
call s1(x,v,e)
end
```
```console
$ flang-new -v test.f90 -fopenmp
flang-new version 19.0.0git (https://github.com/llvm/llvm-project.git 7c3ee7cbe6419ea5e37ce2723cc1a1688380581f)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
Found candidate GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
Selected GCC installation: /opt/rh/gcc-toolset-12/root/usr/lib/gcc/aarch64-redhat-linux/12
Candidate multilib: .;@m64
Selected multilib: .;@m64
 "/path/to/install/bin/flang-new" -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-2c3d6e.o -x f95-cpp-input test.f90
flang-new: /path/to/llvm-project/llvm/lib/IR/Type.cpp:279: static llvm::IntegerType* llvm::IntegerType::get(llvm::LLVMContext&, unsigned int): Assertion `NumBits >= MIN_INT_BITS && "bitwidth too small"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /path/to/install/bin/flang-new -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -fopenmp -fcolor-diagnostics -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu generic -target-feature +v8a -target-feature +fp-armv8 -target-feature +neon -mframe-pointer=non-leaf -o /tmp/test-2c3d6e.o -x f95-cpp-input test.f90
 #0 0x0000ffffb1a25808 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/path/to/install/lib/libLLVMSupport.so.19git+0x1a5808)
 #1 0x0000ffffb1a23738 llvm::sys::RunSignalHandlers() (/path/to/install/lib/libLLVMSupport.so.19git+0x1a3738)
 #2 0x0000ffffb1a238bc SignalHandler(int) Signals.cpp:0:0
 #3 0x0000ffffb43a07a0 (linux-vdso.so.1+0x7a0)
 #4 0x0000ffffb1476274 raise (/lib64/libc.so.6+0x36274)
 #5 0x0000ffffb1460a2c abort (/lib64/libc.so.6+0x20a2c)
 #6 0x0000ffffb146fba0 __assert_fail_base (/lib64/libc.so.6+0x2fba0)
 #7 0x0000ffffb146fc18 __assert_perror_fail (/lib64/libc.so.6+0x2fc18)
 #8 0x0000ffffaed14fd8 llvm::IntegerType::get(llvm::LLVMContext&, unsigned int) (/path/to/install/lib/libLLVMCore.so.19git+0x2e4fd8)
 #9 0x0000ffffa1017050 llvm::OpenMPIRBuilder::emitAtomicUpdate(llvm::IRBuilderBase::InsertPoint, llvm::Value*, llvm::Type*, llvm::Value*, llvm::AtomicOrdering, llvm::AtomicRMWInst::BinOp, llvm::function_ref<llvm::Value* (llvm::Value*, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&)> const&, bool, bool) (/path/to/install/lib/libLLVMFrontendOpenMP.so.19git+0x37050)
#10 0x0000ffffa1038888 llvm::OpenMPIRBuilder::createAtomicCapture(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::IRBuilderBase::InsertPoint, llvm::OpenMPIRBuilder::AtomicOpValue&, llvm::OpenMPIRBuilder::AtomicOpValue&, llvm::Value*, llvm::AtomicOrdering, llvm::AtomicRMWInst::BinOp, llvm::function_ref<llvm::Value* (llvm::Value*, llvm::IRBuilder<llvm::ConstantFolder, llvm::IRBuilderDefaultInserter>&)> const&, bool, bool, bool) (/path/to/install/lib/libLLVMFrontendOpenMP.so.19git+0x58888)
#11 0x0000ffffa0424428 convertOmpAtomicCapture(mlir::omp::AtomicCaptureOp, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#12 0x0000ffffa0433d40 (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const OpenMPToLLVMIRTranslation.cpp:0:0
#13 0x0000ffffa3203ab8 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/path/to/install/lib/libMLIRTargetLLVMIRExport.so.19git+0x23ab8)
#14 0x0000ffffa320e2d4 mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/path/to/install/lib/libMLIRTargetLLVMIRExport.so.19git+0x2e2d4)
#15 0x0000ffffa320ef6c mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/path/to/install/lib/libMLIRTargetLLVMIRExport.so.19git+0x2ef6c)
#16 0x0000ffffa320f6c4 mlir::LLVM::ModuleTranslation::convertFunctions() (/path/to/install/lib/libMLIRTargetLLVMIRExport.so.19git+0x2f6c4)
#17 0x0000ffffa32123f8 mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef) (/path/to/install/lib/libMLIRTargetLLVMIRExport.so.19git+0x323f8)
#18 0x0000ffffb294ed10 Fortran::frontend::CodeGenAction::generateLLVMIR() (/path/to/install/lib/libflangFrontend.so.19git+0x24ed10)
#19 0x0000ffffb2950afc Fortran::frontend::CodeGenAction::executeAction() (/path/to/install/lib/libflangFrontend.so.19git+0x250afc)
#20 0x0000ffffb28908e4 Fortran::frontend::FrontendAction::execute() (/path/to/install/lib/libflangFrontend.so.19git+0x1908e4)
#21 0x0000ffffb28847ec Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/path/to/install/lib/libflangFrontend.so.19git+0x1847ec)
#22 0x0000ffffb2de5020 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/path/to/install/lib/libflangFrontendTool.so.19git+0x5020)
#23 0x0000000000405eb8 fc1_main(llvm::ArrayRef<char const*>, char const*) (/path/to/install/bin/flang-new+0x405eb8)
#24 0x0000000000404ae0 main (/path/to/install/bin/flang-new+0x404ae0)
#25 0x0000ffffb1464384 __libc_start_main (/lib64/libc.so.6+0x24384)
#26 0x0000000000404d28 _start (/path/to/install/bin/flang-new+0x404d28)
flang-new: error: unable to execute command: Aborted (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 7c3ee7cbe6419ea5e37ce2723cc1a1688380581f)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/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/test-8cf1e3
flang-new: note: diagnostic msg: /tmp/test-8cf1e3.sh
flang-new: note: diagnostic msg: 

********************
```
```console
$ gfortran -v test.f90 -fopenmp
Driving: gfortran -v test.f90 -fopenmp -l gfortran -l m -shared-libgcc
Using built-in specs.
COLLECT_GCC=gfortran
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/8/lto-wrapper
Target: aarch64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --disable-libmpx --enable-gnu-indirect-function --build=aarch64-redhat-linux
Thread model: posix
gcc version 8.5.0 20210514 (Red Hat 8.5.0-18) (GCC) 
 :
$
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1z26rW_jXkhpFHQrItX-TCseM2M2mTSbzPvvQgtGTTItALKHHOr38HJNmS89m0s2_O7qSJzcfieRYPayEQNYZvJcA5Gl-g8fKM1nan9PlTbeJpFAbFj7NM5U_n6x03mBtMJebG1IALrUq8qn9wa2pswVhTcwsjFC5ROG9-rwSV20DCI7agSy6pBYNpJpUuqRBP-HEHEjNVVlxwucVoElKrSs4wo5WtNaBJiAulfRMBe_xANaeZGA6y3gEulBDq0dmgGrDdgQeEK622mpaYytwXNkNRy5XEGkwtrMGqwEeYruG2UNpqKgeDoEnY_LSVbSmJ_ECjYhY2JaXKawG4jJqvTElLuTTNN1NnWtWWS8AmQiTdI7J4QGQBiMy69g3RY003DiKJKit84h9f-4Di5b75uEfxMnjWCWTedmxq3PcjlkNZn29t-iReBOXGio4ISGsHxcu47UeFeI3ocbjOsSdfmZJGiQOVBBeHSQoeDk7HQaEqkGXVtDu2eQBt3CxHs1E4CrfcYkTSnbWVQfEckRUiqy23uzobMVUishLiofsTVFr9AGZHrteUxQBTlsEkiWZAxxBPGZApiRmLaDRJ0zgNx2lUHIitqd6CRfEcU6rZbpIEtfwp1aMMBJf1PtjKupOtBprjUuUgXPNKGd7O4pU0lgoB-ZJrV4XIqqJ2h8jKKkRWvKlGZJXxVogrVcscMypznlML-MtigdtmXu2tFVVZRFbaWdoyFlilhAEbRMSVKuUqa6OdH3jWtEFk1fHQkO-obWggsoraCb8HAcxC_k-OuTg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