Skip to content

[flang][OpenMP] MLIR operation conversion leads to segfault #297

@aprell

Description

@aprell

Problem Description

Two target data directives work fine:

!$omp target data map(to: xin) map(from: xout)
!$omp target data use_device_addr(xin, xout)

call hip_kernel(c_loc(xin), c_loc(xout), n)

!$omp end target data
!$omp end target data

However, a single target data directive results in a crash:

!$omp target data map(to: xin) map(from: xout) &
!$omp             use_device_addr(xin, xout)

call hip_kernel(c_loc(xin), c_loc(xout), n)

!$omp end target data

For example, test.f90:

$ amdflang --version
AMD AFAR drop #7.1 08/25/25 flang version 22.0.0git (ssh://github-emu/AMD-Lightning-Internal/llvm-project  25342 a3d6bfccb3a48b20da3a63b273490e61ffa3ec39)

$ amdflang -fopenmp -c test.f90
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: /sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang -fc1 -triple x86_64-unknown-linux-gnu -emit-obj -fcolor-diagnostics -mrelocation-model static -target-cpu x86-64 -fopenmp -resource-dir /sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/lib/clang/22 -mframe-pointer=all -o test.o -x f95 test.f90
 #0 0x00000000021d607b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x21d607b)
 #1 0x00000000021d2ebd SignalHandler(int, siginfo_t*, void*) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x21d2ebd)
 #2 0x00007f70c013c6f0 __restore_rt (/lib64/libc.so.6+0x3e6f0)
 #3 0x0000000005dff78d 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>) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x5dff78d)
 #4 0x00000000042f9072 convertOperationImpl(mlir::Operation&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x42f9072)
 #5 0x0000000005df802e mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x5df802e)
 #6 0x0000000005e01eba mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x5e01eba)
 #7 0x000000000406a88c convertOmpOpRegions(mlir::Region&, llvm::StringRef, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&, llvm::SmallVectorImpl<llvm::PHINode*>*) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x406a88c)
 #8 0x00000000040748d4 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) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x40748d4)
 #9 0x0000000006db2660 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*) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x6db2660)
#10 0x0000000004066928 convertOmpTargetData(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x4066928)
#11 0x000000000408546b (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x408546b)
#12 0x0000000005df802e mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x5df802e)
#13 0x0000000005e01eba mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x5e01eba)
#14 0x0000000005e035f8 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x5e035f8)
#15 0x0000000005e03ed0 mlir::LLVM::ModuleTranslation::convertFunctions() (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x5e03ed0)
#16 0x0000000005e0e245 mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef, bool) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x5e0e245)
#17 0x0000000002502187 Fortran::frontend::CodeGenAction::generateLLVMIR() (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x2502187)
#18 0x0000000002507430 Fortran::frontend::CodeGenAction::executeAction() (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x2507430)
#19 0x00000000022159cd Fortran::frontend::FrontendAction::execute() (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x22159cd)
#20 0x000000000220032b Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x220032b)
#21 0x000000000221f085 Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x221f085)
#22 0x000000000155d6fd fc1_main(llvm::ArrayRef<char const*>, char const*) (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x155d6fd)
#23 0x00000000014488c0 main (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x14488c0)
#24 0x00007f70c0127590 __libc_start_call_main (/lib64/libc.so.6+0x29590)
#25 0x00007f70c0127640 __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x29640)
#26 0x000000000155c14e _start (/sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang+0x155c14e)
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)
AMD AFAR drop #7.1 08/25/25 flang version 22.0.0git (ssh://github-emu/AMD-Lightning-Internal/llvm-project  25342 a3d6bfccb3a48b20da3a63b273490e61ffa3ec39)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin
Build config: +assertions
Configuration file: /sw/hunter-rh9/hlrs/testing/unsupported/rocm-afar/8473-drop-7.1.0/lib/llvm/bin/flang.cfg

Operating System

Red Hat Enterprise Linux 9.4

CPU

AMD EPYC 9354, AMD Instinct MI300A

GPU

AMD Instinct MI300A (gfx942)

ROCm Version

rocm-afar-8473-drop-7.1.0

ROCm Component

flang

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions