Skip to content

[Flang][OpenMP] Compilation error when the same type (complex) is used in capture-statement in atomic read construct #94926

Closed
@ohno-fj

Description

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

In #93441, when a different type is used in capture-statement in atomic read construct, the compilation terminates abnormally.
However, when the same type (complex) is used, the compilation also terminates abnormally.

Compilation ends normally in the following cases:

  • change complex to real, or
  • change complex to integer

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

OMP_3_O_007_4_atm_type_140_re_.f90:

subroutine sub2()
  complex(kind=4) :: s_x_c2, s_v_c2
  s_x_c2 = 10
  s_v_c2 = 10

!$omp atomic read seq_cst
  s_v_c2 = s_x_c2
!$omp end atomic
  write(6,*) "s_v_c2 = ", s_v_c2, " s_x_c2 = ", s_x_c2
end subroutine sub2

program main
  call sub2()
end program main
$ flang-new -fopenmp OMP_3_O_007_4_atm_type_140_re_.f90
flang-new: /lustre/home/ohno/LLVM_20240523/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:5894: llvm::OpenMPIRBuilder::InsertPointTy llvm::OpenMPIRBuilder::createAtomicRead(const llvm::OpenMPIRBuilder::LocationDescription&, llvm::OpenMPIRBuilder::AtomicOpValue&, llvm::OpenMPIRBuilder::AtomicOpValue&, llvm::AtomicOrdering): Assertion `(XElemTy->isFloatingPointTy() || XElemTy->isIntegerTy() || XElemTy->isPointerTy()) && "OMP atomic read expected a scalar type"' failed.
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_20240523/release/bin/flang-new -fc1 -triple aarch64-unknown-linux-gnu -emit-obj -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 -fopenmp -resource-dir /lustre/home/ohno/LLVM_20240523/release/bin/.. -mframe-pointer=non-leaf -o /tmp/OMP_3_O_007_4_atm_type_140_re_-f6c793.o -x f95-cpp-input OMP_3_O_007_4_atm_type_140_re_.f90
 #0 0x0000000004251280 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x4251280)
 #1 0x000000000424f188 llvm::sys::RunSignalHandlers() (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x424f188)
 #2 0x000000000424f30c SignalHandler(int) Signals.cpp:0:0
 #3 0x00004000044607a0 (linux-vdso.so.1+0x7a0)
 #4 0x0000400004906274 raise (/lib64/libc.so.6+0x36274)
 #5 0x00004000048f0a2c abort (/lib64/libc.so.6+0x20a2c)
 #6 0x00004000048ffba0 __assert_fail_base (/lib64/libc.so.6+0x2fba0)
 #7 0x00004000048ffc18 __assert_perror_fail (/lib64/libc.so.6+0x2fc18)
 #8 0x000000000728bf20 llvm::OpenMPIRBuilder::emitTaskwaitImpl(llvm::OpenMPIRBuilder::LocationDescription const&) (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x728bf20)
 #9 0x00000000059d86cc convertHostOrTargetOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#10 0x00000000059d9a5c (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const OpenMPToLLVMIRTranslation.cpp:0:0
#11 0x0000000006047370 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x6047370)
#12 0x00000000060509ec mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x60509ec)
#13 0x00000000060516a0 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x60516a0)
#14 0x000000000605200c mlir::LLVM::ModuleTranslation::convertFunctions() (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x605200c)
#15 0x00000000060569d8 mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef) (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x60569d8)
#16 0x00000000048c3098 Fortran::frontend::CodeGenAction::generateLLVMIR() (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x48c3098)
#17 0x00000000048c53c4 Fortran::frontend::CodeGenAction::executeAction() (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x48c53c4)
#18 0x0000000004285cdc Fortran::frontend::FrontendAction::execute() (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x4285cdc)
#19 0x000000000427ab04 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x427ab04)
#20 0x000000000428b298 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x428b298)
#21 0x0000000003e886d0 fc1_main(llvm::ArrayRef<char const*>, char const*) (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x3e886d0)
#22 0x0000000003dfc138 main (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x3dfc138)
#23 0x00004000048f4384 __libc_start_main (/lib64/libc.so.6+0x24384)
#24 0x0000000003e87554 _start (/lustre/home/ohno/LLVM_20240523/release/bin/flang-new+0x3e87554)
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 8930ba98e01bc66949e482b396f8389d64388359)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /lustre/home/ohno/LLVM_20240523/release/bin
Build config: +assertions
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_3_O_007_4_atm_type_140_re_-65119c
flang-new: note: diagnostic msg: /tmp/OMP_3_O_007_4_atm_type_140_re_-65119c.sh
flang-new: note: diagnostic msg:

********************
$
$ cat /tmp/OMP_3_O_007_4_atm_type_140_re_-65119c
#line "./OMP_3_O_007_4_atm_type_140_re_.f90" 1
      subroutine sub2()
      complex(kind=4) :: s_x_c2, s_v_c2
      s_x_c2 = 10
      s_v_c2 = 10

!$omp atomic read seq_cst
      s_v_c2 = s_x_c2
!$omp end atomic
      write(6,*) "s_v_c2 = ", s_v_c2, " s_x_c2 = ", s_x_c2
      end subroutine sub2

      program main
      call sub2()
      end program main
$
$ cat /tmp/OMP_3_O_007_4_atm_type_140_re_-65119c.sh
# Crash reproducer for clang version 19.0.0git (https://github.com/llvm/llvm-project.git 8930ba98e01bc66949e482b396f8389d64388359)
# Driver args: "-fopenmp" "OMP_3_O_007_4_atm_type_140_re_.f90"
# Original command:  "/lustre/home/ohno/LLVM_20240523/release/bin/flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" "-emit-obj" "-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" "-fopenmp" "-resource-dir" "/lustre/home/ohno/LLVM_20240523/release/bin/.." "-mframe-pointer=non-leaf" "-o" "/tmp/OMP_3_O_007_4_atm_type_140_re_-f6c793.o" "-x" "f95-cpp-input" "OMP_3_O_007_4_atm_type_140_re_.f90"
 "/lustre/home/ohno/LLVM_20240523/release/bin/flang-new" "-fc1" "-triple" "aarch64-unknown-linux-gnu" "-emit-obj" "-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" "-fopenmp" "-mframe-pointer=non-leaf" "-x" "f95-cpp-input" "OMP_3_O_007_4_atm_type_140_re_-65119c"
$
$ gfortran -fopenmp OMP_3_O_007_4_atm_type_140_re_.f90; ./a.out
 s_v_c2 =              (10.0000000,0.00000000)  s_x_c2 =              (10.0000000,0.00000000)
$
$ ifort -qopenmp -diag-disable=10448 OMP_3_O_007_4_atm_type_140_re_.f90; ./a.out
 s_v_c2 =  (10.00000,0.0000000E+00)  s_x_c2 =  (10.00000,0.0000000E+00)
$

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions