Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Flang][OpenMP] Compilation error when type complex is used with expression-stmt in atomic construct #83760

Closed
ohno-fj opened this issue Mar 4, 2024 · 4 comments · Fixed by #92364
Assignees
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] flang:ir flang:openmp

Comments

@ohno-fj
Copy link

ohno-fj commented Mar 4, 2024

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:

      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
$
@ohno-fj ohno-fj added openmp flang Flang issues not falling into any other category labels Mar 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 4, 2024

@llvm/issue-subscribers-openmp

Author: None (ohno-fj)

``` Version of flang-new : 19.0.0(dd7386d)/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:

      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&amp;, 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&amp;, llvm::SetVector&lt;llvm::Value*, llvm::SmallVector&lt;llvm::Value*, 0u&gt;, llvm::DenseSet&lt;llvm::Value*, llvm::DenseMapInfo&lt;llvm::Value*, void&gt;&gt;, 0u&gt;&amp;, llvm::SetVector&lt;llvm::Value*, llvm::SmallVector&lt;llvm::Value*, 0u&gt;, llvm::DenseSet&lt;llvm::Value*, llvm::DenseMapInfo&lt;llvm::Value*, void&gt;&gt;, 0u&gt;&amp;, llvm::BasicBlock*&amp;) const (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x7362a0c)
 #<!-- -->5 0x0000000006f86a78 llvm::OpenMPIRBuilder::createParallel(llvm::OpenMPIRBuilder::LocationDescription const&amp;, llvm::IRBuilderBase::InsertPoint, llvm::function_ref&lt;void (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)&gt;, llvm::function_ref&lt;llvm::IRBuilderBase::InsertPoint (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint, llvm::Value&amp;, llvm::Value&amp;, llvm::Value*&amp;)&gt;, std::function&lt;void (llvm::IRBuilderBase::InsertPoint)&gt;, 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&amp;, mlir::LLVM::ModuleTranslation&amp;) const OpenMPToLLVMIRTranslation.cpp:0:0
 #<!-- -->7 0x0000000005d43f18 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&amp;, llvm::IRBuilderBase&amp;, bool) (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x5d43f18)
 #<!-- -->8 0x0000000005d4ca5c mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&amp;, bool, llvm::IRBuilderBase&amp;, 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&amp;, 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&amp;) (/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&lt;char const*&gt;, 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
$

@EugeneZelenko EugeneZelenko added flang:ir crash Prefer [crash-on-valid] or [crash-on-invalid] flang:openmp and removed openmp flang Flang issues not falling into any other category labels Mar 4, 2024
@llvmbot
Copy link
Member

llvmbot commented Mar 4, 2024

@llvm/issue-subscribers-flang-ir

Author: None (ohno-fj)

``` Version of flang-new : 19.0.0(dd7386d)/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:

      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&amp;, 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&amp;, llvm::SetVector&lt;llvm::Value*, llvm::SmallVector&lt;llvm::Value*, 0u&gt;, llvm::DenseSet&lt;llvm::Value*, llvm::DenseMapInfo&lt;llvm::Value*, void&gt;&gt;, 0u&gt;&amp;, llvm::SetVector&lt;llvm::Value*, llvm::SmallVector&lt;llvm::Value*, 0u&gt;, llvm::DenseSet&lt;llvm::Value*, llvm::DenseMapInfo&lt;llvm::Value*, void&gt;&gt;, 0u&gt;&amp;, llvm::BasicBlock*&amp;) const (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x7362a0c)
 #<!-- -->5 0x0000000006f86a78 llvm::OpenMPIRBuilder::createParallel(llvm::OpenMPIRBuilder::LocationDescription const&amp;, llvm::IRBuilderBase::InsertPoint, llvm::function_ref&lt;void (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)&gt;, llvm::function_ref&lt;llvm::IRBuilderBase::InsertPoint (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint, llvm::Value&amp;, llvm::Value&amp;, llvm::Value*&amp;)&gt;, std::function&lt;void (llvm::IRBuilderBase::InsertPoint)&gt;, 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&amp;, mlir::LLVM::ModuleTranslation&amp;) const OpenMPToLLVMIRTranslation.cpp:0:0
 #<!-- -->7 0x0000000005d43f18 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&amp;, llvm::IRBuilderBase&amp;, bool) (/lustre/home/ohno/LLVM_20240219/release/bin/flang-new+0x5d43f18)
 #<!-- -->8 0x0000000005d4ca5c mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&amp;, bool, llvm::IRBuilderBase&amp;, 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&amp;, 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&amp;) (/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&lt;char const*&gt;, 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
$

@NimishMishra
Copy link
Contributor

@Thirumalai-Shaktivel
Copy link
Member

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

NimishMishra added a commit that referenced this issue Oct 3, 2024
…xchange libcalls for complex types in atomic update (#92364)

This patch adds functionality to emit relevant libcalls in case
atomicrmw instruction can not be emitted (for instance, in case of
complex types). The IRBuilder is modified to directly emit __atomic_load
and __atomic_compare_exchange libcalls. The added functions follow a
similar codegen path as Clang, so that LLVM Flang generates almost
similar IR as Clang.

Fixes #83760 and
#75138

Co-authored-by: Michael Kruse <llvm-project@meinersbur.de>
xgupta pushed a commit to xgupta/llvm-project that referenced this issue Oct 4, 2024
…xchange libcalls for complex types in atomic update (llvm#92364)

This patch adds functionality to emit relevant libcalls in case
atomicrmw instruction can not be emitted (for instance, in case of
complex types). The IRBuilder is modified to directly emit __atomic_load
and __atomic_compare_exchange libcalls. The added functions follow a
similar codegen path as Clang, so that LLVM Flang generates almost
similar IR as Clang.

Fixes llvm#83760 and
llvm#75138

Co-authored-by: Michael Kruse <llvm-project@meinersbur.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
crash Prefer [crash-on-valid] or [crash-on-invalid] flang:ir flang:openmp
5 participants