llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.03k stars 11.57k forks source link

[Flang][OpenMP] Compilation error of `atomic capture` for complex variable #80397

Open yus3710-fj opened 7 months ago

yus3710-fj commented 7 months ago

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.

! 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
$ 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: 

********************
$ 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) 
 :
$
llvmbot commented 7 months ago

@llvm/issue-subscribers-flang-ir

Author: Yusuke MINATO (yus3710-fj)

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) : $ ```
ceseo commented 2 months ago

FYI, this happens because emitAtomicUpdate doesn't currently support complex data types.

kiranchandramohan commented 2 months ago

@ceseo @NimishMishra is working on this issue. https://github.com/llvm/llvm-project/pull/92364

Thirumalai-Shaktivel commented 1 day ago

I get the LLVM Error with the latest main

$ flang-new x.f90 -fopenmp && ./a.out
error: ~/Projects/llvm-project/flang/lib/Lower/DirectivesCommon.h:163: not yet implemented: Unsupported atomic type
LLVM ERROR: aborting