Skip to content

[Flang][OpenMP] crashes when using non-C_PTR type in USE_DEVICE_PTR #145216

Open
@k-arrows

Description

@k-arrows

Reproducer:
https://godbolt.org/z/569voxf9z

use iso_c_binding, only: c_loc, c_ptr
real, allocatable, target :: arr(:,:)
type(c_ptr) :: devptr

!$omp target data use_device_ptr(arr)
devptr = c_loc(arr(1,1))
!$omp end target data

end

Backtrace:

flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
/app/example.f90:5:19: warning: Use of non-C_PTR type 'arr' in USE_DEVICE_PTR is deprecated, use USE_DEVICE_ADDR instead
  !$omp target data use_device_ptr(arr)
                    ^^^^^^^^^^^^^^^^^^^
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-20250622/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-20250622/lib/clang/21 -mframe-pointer=all -o /app/output.s -x f95 /app/example.f90
 #0 0x0000000003e78268 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x3e78268)
 #1 0x0000000003e75e24 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #2 0x00007537ac042520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #3 0x0000000007613cd5 mlir::LLVM::detail::createIntrinsicCall(llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&, mlir::Operation*, unsigned int, unsigned int, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<unsigned int>, llvm::ArrayRef<llvm::StringLiteral>) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x7613cd5)
 #4 0x0000000005e55588 convertOperationImpl(mlir::Operation&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) LLVMToLLVMIRTranslation.cpp:0:0
 #5 0x000000000760f9c6 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x760f9c6)
 #6 0x000000000760fddb mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x760fddb)
 #7 0x0000000005c5ef62 inlineConvertOmpRegions(mlir::Region&, llvm::StringRef, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&, llvm::SmallVectorImpl<llvm::Value*>*) OpenMPToLLVMIRTranslation.cpp:0:0
 #8 0x0000000005c624c4 llvm::Expected<llvm::IRBuilderBase::InsertPoint> llvm::function_ref<llvm::Expected<llvm::IRBuilderBase::InsertPoint> (llvm::IRBuilderBase::InsertPoint, llvm::OpenMPIRBuilder::BodyGenTy)>::callback_fn<convertOmpTargetData(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&)::'lambda6'(llvm::IRBuilderBase::InsertPoint, llvm::OpenMPIRBuilder::BodyGenTy)>(long, llvm::IRBuilderBase::InsertPoint, llvm::OpenMPIRBuilder::BodyGenTy) OpenMPToLLVMIRTranslation.cpp:0:0
 #9 0x00000000081722d4 llvm::OpenMPIRBuilder::createTargetData(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint, llvm::Value*, llvm::Value*, llvm::OpenMPIRBuilder::TargetDataInfo&, llvm::function_ref<llvm::OpenMPIRBuilder::MapInfosTy& (llvm::IRBuilderBase::InsertPoint)>, llvm::function_ref<llvm::Expected<llvm::Function*> (unsigned int)>, llvm::omp::RuntimeFunction*, llvm::function_ref<llvm::Expected<llvm::IRBuilderBase::InsertPoint> (llvm::IRBuilderBase::InsertPoint, llvm::OpenMPIRBuilder::BodyGenTy)>, llvm::function_ref<void (unsigned int, llvm::Value*)>, llvm::Value*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x81722d4)
#10 0x0000000005c566bb convertOmpTargetData(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#11 0x0000000005c75a3b convertHostOrTargetOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#12 0x0000000005c75fa5 (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const OpenMPToLLVMIRTranslation.cpp:0:0
#13 0x000000000760f9c6 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x760f9c6)
#14 0x000000000760fddb mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x760fddb)
#15 0x00000000076155f3 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x76155f3)
#16 0x0000000007616db8 mlir::LLVM::ModuleTranslation::convertFunctions() (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x7616db8)
#17 0x000000000761f35e mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef, bool) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x761f35e)
#18 0x000000000418ad0f Fortran::frontend::CodeGenAction::generateLLVMIR() (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x418ad0f)
#19 0x0000000004190438 Fortran::frontend::CodeGenAction::executeAction() (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x4190438)
#20 0x0000000003ed099d Fortran::frontend::FrontendAction::execute() (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x3ed099d)
#21 0x0000000003ebea78 Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x3ebea78)
#22 0x0000000003eda0d3 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x3eda0d3)
#23 0x0000000002216b3a fc1_main(llvm::ArrayRef<char const*>, char const*) (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x2216b3a)
#24 0x00000000020c5846 main (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x20c5846)
#25 0x00007537ac029d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#26 0x00007537ac029e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#27 0x0000000002215505 _start (/opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin/flang+0x2215505)
flang-21: error: unable to execute command: Segmentation fault (core dumped)
flang-21: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 21.0.0git (https://github.com/llvm/llvm-project.git f280d3b705de7f94ef9756e3ef2842b415a7c038)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-llvmflang-trunk-20250622/bin
flang-21: warning: OpenMP support in flang is still experimental [-Wexperimental-option]
flang-21: 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