Skip to content

[Flang][OpenMP] Compilation error when capture-statement described in atomic read construct contains a different type #93441

Closed
@ohno-fj

Description

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

When capture-statement described in atomic read construct contains a different type, the compilation terminates abnormally.

Compilation ends normally in the following cases:

  • Do not specify the compilation option (-fopenmp)

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

OMP_3_O_007_4_atm_type_006_re_22.f90:

subroutine sub2()
  real(kind=4)    :: s_v_r2
  complex(kind=4) :: s_x_c2
  s_v_r2 = 0.0
  s_x_c2 = (1.0,2.0)
!$omp atomic read
   s_v_r2 = s_x_c2
!$omp end atomic
   write(6,*) "s_v_r2 = ", s_v_r2
end subroutine sub2

program main
  call sub2()
end program
$ flang-new -fopenmp OMP_3_O_007_4_atm_type_006_re_22.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_006_re_22-4aae60.o -x f95-cpp-input OMP_3_O_007_4_atm_type_006_re_22.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 0x000040002da507a0 (linux-vdso.so.1+0x7a0)
 #4 0x000040002def6274 raise (/lib64/libc.so.6+0x36274)
 #5 0x000040002dee0a2c abort (/lib64/libc.so.6+0x20a2c)
 #6 0x000040002deefba0 __assert_fail_base (/lib64/libc.so.6+0x2fba0)
 #7 0x000040002deefc18 __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 0x000040002dee4384 __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_006_re_22-0ff303
flang-new: note: diagnostic msg: /tmp/OMP_3_O_007_4_atm_type_006_re_22-0ff303.sh
flang-new: note: diagnostic msg:

********************
$
$ cat /tmp/OMP_3_O_007_4_atm_type_006_re_22-0ff303
#line "./OMP_3_O_007_4_atm_type_006_re_22.f90" 1
      subroutine sub2()
      real(kind=4) :: s_v_r2
      complex(kind=4) :: s_x_c2
      s_v_r2 = 0.0
      s_x_c2 =(1.0,2.0)
!$omp atomic read
      s_v_r2 = s_x_c2
!$omp end atomic
      write(6,*) "s_v_r2 = ", s_v_r2
      end subroutine sub2

      program main
      call sub2()
      end program
$ cat /tmp/OMP_3_O_007_4_atm_type_006_re_22-0ff303.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_006_re_22.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_006_re_22-4aae60.o" "-x" "f95-cpp-input" "OMP_3_O_007_4_atm_type_006_re_22.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_006_re_22-0ff303"
$
$ gfortran -fopenmp OMP_3_O_007_4_atm_type_006_re_22.f90
 s_v_r2 =    1.00000000
$
$ ifort -qopenmp -diag-disable=10448 OMP_3_O_007_4_atm_type_006_re_22.f90
 s_v_r2 =    1.000000
$

Metadata

Metadata

Labels

llvm:openmpirbuilderIssues related to problems in the llvm-project/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions