Skip to content

[Flang][OpenMP] crashes with OpenMP target teams followed by distribute parallel do #150747

@k-arrows

Description

@k-arrows

Reproducer:
https://godbolt.org/z/615K3sdcG

!$omp target teams
call foo()

!$omp distribute parallel do
do i=1,2
end do
!$omp end distribute parallel do
!$omp end target teams
end

Backtrace:

PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.	Program arguments: /opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang -fc1 -triple x86_64-unknown-linux-gnu -S -mrelocation-model pic -pic-level 2 -pic-is-pie -target-cpu x86-64 -mllvm -x86-asm-syntax=intel -fopenmp -resource-dir /opt/compiler-explorer/clang-llvmflang-trunk-20250726/lib/clang/22 -mframe-pointer=all -o /app/output.s -x f95 /app/example.f90
 #0 0x00000000041554f8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x41554f8)
 #1 0x00000000041526c4 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x000077da15042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000000008644ad7 llvm::OpenMPIRBuilder::calculateCanonicalLoopTripCount(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::Value*, llvm::Value*, llvm::Value*, bool, bool, llvm::Twine const&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x8644ad7)
 #4 0x0000000005ee42c1 convertOmpTarget(mlir::Operation&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
 #5 0x0000000005ef960a convertHostOrTargetOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
 #6 0x0000000005efab95 (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const OpenMPToLLVMIRTranslation.cpp:0:0
 #7 0x00000000079acef6 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x79acef6)
 #8 0x00000000079ad30b mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x79ad30b)
 #9 0x00000000079b6ef3 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x79b6ef3)
#10 0x00000000079b8308 mlir::LLVM::ModuleTranslation::convertFunctions() (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x79b8308)
#11 0x00000000079bd0b6 mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x79bd0b6)
#12 0x0000000004459e9e Fortran::frontend::CodeGenAction::generateLLVMIR() (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x4459e9e)
#13 0x000000000445f6a8 Fortran::frontend::CodeGenAction::executeAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x445f6a8)
#14 0x00000000041aebcd Fortran::frontend::FrontendAction::execute() (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x41aebcd)
#15 0x000000000419cc3f Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x419cc3f)
#16 0x00000000041b7b4b Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x41b7b4b)
#17 0x00000000024b4c4a fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x24b4c4a)
#18 0x0000000002359c06 main (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x2359c06)
#19 0x000077da15029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#20 0x000077da15029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#21 0x00000000024b3605 _start (/opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin/flang+0x24b3605)
flang-22: error: unable to execute command: Segmentation fault (core dumped)
flang-22: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 22.0.0git (https://github.com/llvm/llvm-project.git 799f28d7a5f155ae5456c87a511fbd18498f6396)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20250726/bin
flang-22: note: diagnostic msg: 

Metadata

Metadata

Assignees

No one assigned

    Labels

    crashPrefer [crash-on-valid] or [crash-on-invalid]flang:openmp

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions