llvm / llvm-project

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

[Flang][OpenMP] Compilation error of the update-statement of `atomic` constructs #64285

Closed yus3710-fj closed 8 months ago

yus3710-fj commented 1 year ago

This is an issue from Fujitsu testsuite.

Flang-new terminates abnormally when compiling atomic constructs. I couldn't find the minimal conditions to reproduce this issue.

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

! test.f90
integer(kind=4) :: iaa
integer(kind=4) :: ibb
integer(kind=4) :: icc
iaa=1
ibb=1
icc=1

!$OMP atomic
iaa=(1+ibb*2)+iaa ! flang-new fails
! $OMP atomic
!iaa=+icc*ibb*2*iaa ! gfortran/ifort fails

end
$ flang-new -v test.f90 -fopenmp
flang-new version 17.0.0 (https://github.com/llvm/llvm-project.git e126fa27c07c83997fcdee2bd45996ffc860317b)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /path/to/install/bin
Found candidate GCC installation: /opt/rh/gcc-toolset-10/root/usr/lib/gcc/aarch64-redhat-linux/10
Selected GCC installation: /opt/rh/gcc-toolset-10/root/usr/lib/gcc/aarch64-redhat-linux/10
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 +neon -target-feature +v8a -o /tmp/test-b64af8.o -x f95-cpp-input test.f90
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 +neon -target-feature +v8a -o /tmp/test-b64af8.o -x f95-cpp-input test.f90
 #0 0x0000ffffa5d40900 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/path/to/install/bin/../lib/libLLVMSupport.so.17git+0x1a0900)
 #1 0x0000ffffa5d3e9e0 llvm::sys::RunSignalHandlers() (/path/to/install/bin/../lib/libLLVMSupport.so.17git+0x19e9e0)
 #2 0x0000ffffa5d3eb50 SignalHandler(int) Signals.cpp:0:0
 #3 0x0000ffffa78007a0 (linux-vdso.so.1+0x7a0)
 #4 0x0000ffff9d8831fc 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/bin/../lib/../lib/libLLVMFrontendOpenMP.so.17git+0x431fc)
 #5 0x0000ffff9d894600 llvm::OpenMPIRBuilder::createAtomicUpdate(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::IRBuilderBase::InsertPoint, 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) (/path/to/install/bin/../lib/../lib/libLLVMFrontendOpenMP.so.17git+0x54600)
 #6 0x0000ffff99f0204c convertOmpAtomicUpdate(mlir::omp::AtomicUpdateOp&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
 #7 0x0000ffff99f0c93c (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const OpenMPToLLVMIRTranslation.cpp:0:0
 #8 0x0000ffff9da71114 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&) (/path/to/install/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.17git+0x21114)
 #9 0x0000ffff9da7c394 mlir::LLVM::ModuleTranslation::convertBlock(mlir::Block&, bool, llvm::IRBuilderBase&) (/path/to/install/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.17git+0x2c394)
#10 0x0000ffff9da7f044 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/path/to/install/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.17git+0x2f044)
#11 0x0000ffff9da7f694 mlir::LLVM::ModuleTranslation::convertFunctions() (/path/to/install/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.17git+0x2f694)
#12 0x0000ffff9da7fdfc mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef) (/path/to/install/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.17git+0x2fdfc)
#13 0x0000ffffa6a17b4c Fortran::frontend::CodeGenAction::generateLLVMIR() (/path/to/install/bin/../lib/libflangFrontend.so.17git+0x117b4c)
#14 0x0000ffffa6a1963c Fortran::frontend::CodeGenAction::executeAction() (/path/to/install/bin/../lib/libflangFrontend.so.17git+0x11963c)
#15 0x0000ffffa695047c Fortran::frontend::FrontendAction::execute() (/path/to/install/bin/../lib/libflangFrontend.so.17git+0x5047c)
#16 0x0000ffffa6943334 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/path/to/install/bin/../lib/libflangFrontend.so.17git+0x43334)
#17 0x0000ffffa6ea30a8 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/path/to/install/bin/../lib/libflangFrontendTool.so.17git+0x30a8)
#18 0x0000000000404870 fc1_main(llvm::ArrayRef<char const*>, char const*) (/path/to/install/bin/flang-new+0x404870)
#19 0x0000000000403104 main (/path/to/install/bin/flang-new+0x403104)
#20 0x0000ffffa5710de4 __libc_start_main (/lib64/libc.so.6+0x20de4)
#21 0x00000000004035d0 _start (/path/to/install/bin/flang-new+0x4035d0)
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 17.0.0 (https://github.com/llvm/llvm-project.git e126fa27c07c83997fcdee2bd45996ffc860317b)
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-e5acc3
flang-new: note: diagnostic msg: /tmp/test-e5acc3.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.4.1 20200928 (Red Hat 8.4.1-1) (GCC) 
 :
$
llvmbot commented 1 year ago

@llvm/issue-subscribers-flang-ir

kiranchandramohan commented 1 year ago

@NimishMishra Could you have a look?

NimishMishra commented 1 year ago

Assigning myself. Will look into it.

yus3710-fj commented 9 months ago

It seems to be fixed. Thank you. Could you close thie issue if there is no problem?

$ flang-new -v test.f90 -fopenmp
flang-new version 18.0.0 (https://github.com/llvm/llvm-project.git 52848d001766ea2deb5705458632d4b0efe8ea34)
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
 :
$
ceseo commented 8 months ago

This is fixed by 04e9b61ce. Closing.