Skip to content

[Flang][OpenMP] Compilation error for statement in atomic construct #85595

@ohno-fj

Description

@ohno-fj
Version of flang-new : 19.0.0(00efb343529cce025055ca8284a61b22b48924c9)/AArch64

The compilation is an error if statement in atomic construct is:

  • operation of integer (kind=1) variable, or (omp_atomic_001_2.f90)
  • operation of integer (kind=2) variable, or (omp_atomic_002_2.f90)
  • operation of integer(kind=4) and integer(kind=8), or (omp_atomic_003_2.f90)
  • operation of integer(kind=8) and real(kind=8), or (omp_atomic_004_2.f90)
  • operation of real(kind=4) and real(kind=8), or (omp_atomic_005_2.f90)
  • operation of real(kind=8) and real(kind=16) (omp_atomic_006_2.f90)

The above conditions result in the same error.
Each program is attached at the end.

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

omp_atomic_001_2.f90:

program main
  integer(1)::i1=5

!$omp parallel
!$omp atomic
  i1=i1+1
!$omp atomic
  i1=i1-1
!$omp end parallel

end program main
$ flang-new -fopenmp omp_atomic_001_2.f90
error: loc("/work/home/ohno/CT/test/fort/tp/reproducerJ/fomp_omp30/omp_atomic_001_2.f90":1:1): 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_omp30/omp_atomic_001_2.f90":1:1): 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_20240307/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_atomic_001_2-3539fb.o -x f95-cpp-input omp_atomic_001_2.f90
 #0 0x00000000040dc3d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x40dc3d8)
 #1 0x00000000040da2e0 llvm::sys::RunSignalHandlers() (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x40da2e0)
 #2 0x00000000040da464 SignalHandler(int) Signals.cpp:0:0
 #3 0x0000400005c607a0 (linux-vdso.so.1+0x7a0)
 #4 0x0000000007467644 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_20240307/release/bin/flang-new+0x7467644)
 #5 0x0000000007088810 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_20240307/release/bin/flang-new+0x7088810)
 #6 0x000000000579bd40 (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const OpenMPToLLVMIRTranslation.cpp:0:0
 #7 0x0000000005e2b420 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x5e2b420)
 #8 0x0000000005e34274 mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x5e34274)
 #9 0x0000000005e34f20 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x5e34f20)
#10 0x0000000005e358f0 mlir::LLVM::ModuleTranslation::convertFunctions() (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x5e358f0)
#11 0x0000000005e3a2cc mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef) (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x5e3a2cc)
#12 0x000000000472db08 Fortran::frontend::CodeGenAction::generateLLVMIR() (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x472db08)
#13 0x000000000472fcc8 Fortran::frontend::CodeGenAction::executeAction() (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x472fcc8)
#14 0x00000000041112fc Fortran::frontend::FrontendAction::execute() (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x41112fc)
#15 0x0000000004105b6c Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x4105b6c)
#16 0x0000000004115f78 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x4115f78)
#17 0x0000000003d2e4a8 fc1_main(llvm::ArrayRef<char const*>, char const*) (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x3d2e4a8)
#18 0x0000000003cb6890 main (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x3cb6890)
#19 0x00004000060f4384 __libc_start_main (/lib64/libc.so.6+0x24384)
#20 0x0000000003d2d32c _start (/lustre/home/ohno/LLVM_20240307/release/bin/flang-new+0x3d2d32c)
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 00efb343529cce025055ca8284a61b22b48924c9)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /lustre/home/ohno/LLVM_20240307/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_atomic_001_2-6d2762
flang-new: note: diagnostic msg: /tmp/omp_atomic_001_2-6d2762.sh
flang-new: note: diagnostic msg:

********************
$
$ cat /tmp/omp_atomic_001_2-6d2762
#line "./omp_atomic_001_2.f90" 1
      program main
      integer(1)::i1=5

!$omp parallel
!$omp atomic
      i1=i1+1
!$omp atomic
      i1=i1-1
!$omp end parallel

      end program main
$
$ cat /tmp/omp_atomic_001_2-6d2762.sh
# Crash reproducer for clang version 19.0.0git (https://github.com/llvm/llvm-project.git 00efb343529cce025055ca8284a61b22b48924c9)
# Driver args: "-fopenmp" "omp_atomic_001_2.f90"
# Original command:  "/lustre/home/ohno/LLVM_20240307/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_atomic_001_2-3539fb.o" "-x" "f95-cpp-input" "omp_atomic_001_2.f90"
 "/lustre/home/ohno/LLVM_20240307/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_atomic_001_2-6d2762"
$
$ export OMP_NUM_THREADS=2; gfortran -fopenmp omp_atomic_001_2.f90; ./a.out
 i1 =     5
$
$ export OMP_NUM_THREADS=2; ifort -qopenmp -diag-disable=10448 omp_atomic_001_2.f90; ./a.out
 i1 =     5

$

omp_atomic_002_2.f90:

program main
  integer(2)::i2=5

!$omp parallel
!$omp atomic
  i2=i2+1
!$omp atomic
  i2=i2-1
!$omp end parallel

end program main

omp_atomic_003_2.f90:

program main
  integer(4)::i4=5
  integer(8)::a=10

!$omp parallel
!$omp atomic
  i4=i4+a
!$omp end parallel

end program main

omp_atomic_004_2.f90:

program main
  integer(8)::i8=5
  real(8)::a=10

!$omp parallel
!$omp atomic
  i8=i8+a
!$omp end parallel

end program main

omp_atomic_005_2.f90:

program main
  real(4)::r4=5
  real(8)::a=10

!$omp parallel
!$omp atomic
  r4=r4+a
!$omp end parallel

end program main

omp_atomic_006_2.f90:

program main
  real(8)::r8=5
  real(16)::a=10

!$omp parallel
!$omp atomic
  r8=r8+a
!$omp end parallel

end program main

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions