Skip to content

[Flang][OpenMP] Compilation error (Aborted) of reduction operation on a do loop containing a subroutine call #79781

Closed
@ohno-fj

Description

@ohno-fj
Version of flang-new : 18.0.0(0fe86f9c518fb1296bba8d66ce495f9dfff2c435)

Reduction operation of a do loop containing a subroutine call terminates abnormally when compiled.

Compilation terminates normally in the following case:

  1. Specify the following option or
    -flang-deprecated-no-hlfir
  2. Change the argument of the subroutine call from an array to a variable:
  • Before the change
        call sss(arr(i))
    
  • After the change
        call sss(i)
    

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

test01.f90:

program main
  call test01()
  print *,"pass"
end program main

subroutine sss(ii)
  i=ii
  i=i
end subroutine sss

subroutine test01()
  integer arr(10)
  arr=1
  i=1
!$omp parallel do reduction(+:i)
  do j=1,1
     i=1
     call sss(arr(i))
     i=100
  end do
!$omp end parallel do
  write(6,*) "i = ", i
end subroutine test01
$ flang-new -fopenmp test01.f90
flang-new: /lustre/home/ohno/LLVM_20240109/llvm-project/llvm/lib/IR/Instructions.cpp:2896: void llvm::BinaryOperator::AssertOK(): Assertion `getType()->isIntOrIntVectorTy() && "Tried to create an integer operation on a non-integer 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_20240109/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 +neon -target-feature +v8a -mframe-pointer=non-leaf -o /tmp/test01-3e03bb.o -x f95-cpp-input test01.f90
 #0 0x0000000003fc4a20 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x3fc4a20)
 #1 0x0000000003fc2928 llvm::sys::RunSignalHandlers() (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x3fc2928)
 #2 0x0000000003fc2aac SignalHandler(int) Signals.cpp:0:0
 #3 0x00004000361f07a0 (linux-vdso.so.1+0x7a0)
 #4 0x00004000365e6274 raise (/lib64/libc.so.6+0x36274)
 #5 0x00004000365d0a2c abort (/lib64/libc.so.6+0x20a2c)
 #6 0x00004000365dfba0 __assert_fail_base (/lib64/libc.so.6+0x2fba0)
 #7 0x00004000365dfc18 __assert_perror_fail (/lib64/libc.so.6+0x2fc18)
 #8 0x0000000007bc0e74 llvm::BinaryOperator::AssertOK() (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x7bc0e74)
 #9 0x0000000007bc1304 llvm::BinaryOperator::Create(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, llvm::Twine const&, llvm::Instruction*) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x7bc1304)
#10 0x000000000561b60c llvm::IRBuilderBase::CreateInsertNUWNSWBinOp(llvm::Instruction::BinaryOps, llvm::Value*, llvm::Value*, llvm::Twine const&, bool, bool) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x561b60c)
#11 0x0000000005a81e9c convertOperationImpl(mlir::Operation&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) LLVMToLLVMIRTranslation.cpp:0:0
#12 0x0000000005c794f0 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x5c794f0)
#13 0x0000000005c82484 mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x5c82484)
#14 0x0000000005623d64 inlineConvertOmpRegions(mlir::Region&, llvm::StringRef, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&, llvm::SmallVectorImpl<llvm::Value*>*) OpenMPToLLVMIRTranslation.cpp:0:0
#15 0x0000000005628be4 convertOmpReductionOp(mlir::omp::ReductionOp, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#16 0x000000000562af28 (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const OpenMPToLLVMIRTranslation.cpp:0:0
#17 0x0000000005c794f0 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x5c794f0)
#18 0x0000000005c82484 mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x5c82484)
#19 0x0000000005622d50 convertOmpOpRegions(mlir::Region&, llvm::StringRef, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&, mlir::LogicalResult&, llvm::SmallVectorImpl<llvm::PHINode*>*) OpenMPToLLVMIRTranslation.cpp:0:0
#20 0x0000000006e587f0 void llvm::function_ref<void (llvm::IRBuilderBase::InsertPoint, llvm::Value*)>::callback_fn<llvm::OpenMPIRBuilder::createCanonicalLoop(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::function_ref<void (llvm::IRBuilderBase::InsertPoint, llvm::Value*)>, llvm::Value*, llvm::Value*, llvm::Value*, bool, bool, llvm::IRBuilderBase::InsertPoint, llvm::Twine const&)::'lambda'(llvm::IRBuilderBase::InsertPoint, llvm::Value*)>(long, llvm::IRBuilderBase::InsertPoint, llvm::Value*) OMPIRBuilder.cpp:0:0
#21 0x0000000006e5c3e4 llvm::OpenMPIRBuilder::createCanonicalLoop(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::function_ref<void (llvm::IRBuilderBase::InsertPoint, llvm::Value*)>, llvm::Value*, llvm::Twine const&) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x6e5c3e4)
#22 0x0000000006e5c704 llvm::OpenMPIRBuilder::createCanonicalLoop(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::function_ref<void (llvm::IRBuilderBase::InsertPoint, llvm::Value*)>, llvm::Value*, llvm::Value*, llvm::Value*, bool, bool, llvm::IRBuilderBase::InsertPoint, llvm::Twine const&) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x6e5c704)
#23 0x0000000005629ab0 convertOmpWsLoop(mlir::Operation&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#24 0x000000000562b410 (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const OpenMPToLLVMIRTranslation.cpp:0:0
#25 0x0000000005c794f0 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x5c794f0)
#26 0x0000000005c82484 mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x5c82484)
#27 0x0000000005622d50 convertOmpOpRegions(mlir::Region&, llvm::StringRef, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&, mlir::LogicalResult&, llvm::SmallVectorImpl<llvm::PHINode*>*) OpenMPToLLVMIRTranslation.cpp:0:0
#28 0x000000000562cbd8 convertOmpParallel(mlir::omp::ParallelOp, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&)::'lambda'(llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)::operator()(llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint) const OpenMPToLLVMIRTranslation.cpp:0:0
#29 0x0000000006e85480 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_20240109/release/bin/flang-new+0x6e85480)
#30 0x000000000562ae4c (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const OpenMPToLLVMIRTranslation.cpp:0:0
#31 0x0000000005c794f0 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x5c794f0)
#32 0x0000000005c82484 mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x5c82484)
#33 0x0000000005c830dc mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x5c830dc)
#34 0x0000000005c837c0 mlir::LLVM::ModuleTranslation::convertFunctions() (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x5c837c0)
#35 0x0000000005c85ed4 mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x5c85ed4)
#36 0x0000000004607758 Fortran::frontend::CodeGenAction::generateLLVMIR() (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x4607758)
#37 0x0000000004609348 Fortran::frontend::CodeGenAction::executeAction() (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x4609348)
#38 0x0000000003ff8edc Fortran::frontend::FrontendAction::execute() (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x3ff8edc)
#39 0x0000000003fed5dc Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x3fed5dc)
#40 0x0000000003ffdb58 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x3ffdb58)
#41 0x0000000003c27188 fc1_main(llvm::ArrayRef<char const*>, char const*) (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x3c27188)
#42 0x0000000003bb2990 main (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x3bb2990)
#43 0x00004000365d4384 __libc_start_main (/lib64/libc.so.6+0x24384)
#44 0x0000000003c26004 _start (/lustre/home/ohno/LLVM_20240109/release/bin/flang-new+0x3c26004)
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 18.0.0git (https://github.com/llvm/llvm-project.git 0fe86f9c518fb1296bba8d66ce495f9dfff2c435)
Target: aarch64-unknown-linux-gnu
Thread model: posix
InstalledDir: /lustre/home/ohno/LLVM_20240109/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/test01-77e9b0
flang-new: note: diagnostic msg: /tmp/test01-77e9b0.sh
flang-new: note: diagnostic msg:

********************
$
$ cat /tmp/test01-77e9b0
#line "./test01.f90" 1
      program main
      call test01()
      print *,"pass"
      end program main

      subroutine sss(ii)
      i=ii
      i=i
      end subroutine sss

      subroutine test01()
      integer arr(10)
      arr=1
      i=1
!$omp parallel do reduction(+:i)
      do j=1,1
      i=1
      call sss(arr(i))
      i=100
      end do
!$omp end parallel do
      write(6,*) "i = ", i
      end subroutine test01
$
$ cat /tmp/test01-77e9b0.sh
# Crash reproducer for clang version 18.0.0git (https://github.com/llvm/llvm-project.git 0fe86f9c518fb1296bba8d66ce495f9dfff2c435)
# Driver args: "-fopenmp" "test01.f90"
# Original command:  "/lustre/home/ohno/LLVM_20240109/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" "+neon" "-target-feature" "+v8a" "-mframe-pointer=non-leaf" "-o" "/tmp/\
test01-3e03bb.o" "-x" "f95-cpp-input" "test01.f90"
 "/lustre/home/ohno/LLVM_20240109/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" "+neon" "-target-feature" "+v8a" "-mframe-pointer=non-leaf" "-x" "f95-cpp-input" "test01-77\
e9b0"
$
$ flang-new -fopenmp test01.f90 -flang-deprecated-no-hlfir
$
$ gfortran -fopenmp test01.f90
$
$ ifort -qopenmp -diag-disable=10448 test01.f90
$

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