Issue 172840
Summary [LLVM Flang][OpenMP][target] Compiler crash in target construct
Labels flang
Assignees
Reporter sharangk12
    
The following test is failing with segfault when the target construct is used for x86_64 offloading. 

```fortran
program test
    integer :: x

 !$omp target if(x > (N - 1)) map(tofrom: x)
        x = x + 1
    !$omp end target
end program
```
 

Crash:

$ flang -fopenmp -g -fopenmp-targets=x86_64-pc-linux-gnu  x.f90

```
No grid value available for this architecture!
UNREACHABLE executed at /home/amd/llvm-flang-project/community-llvm-flang/llvm-project/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp:178!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and instructions to reproduce the bug.
Stack dump:
0.  Program arguments: /home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang -fc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelocation-model pic -pic-level 2 -target-cpu x86-64 -fopenmp -resource-dir /home/amd/llvm-flang-project/community-llvm-flang/community_install/lib/clang/22 -fopenmp-host-ir-file-path /tmp/test-b14d32.bc -fopenmp-is-target-device -mframe-pointer=all -o /tmp/test-51544f.o -x f95 test.f90
 #0 0x000056102b7f5c02 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x1afec02)
 #1 0x000056102b7f28ff llvm::sys::RunSignalHandlers() (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x1afb8ff)
 #2 0x000056102b7f2a51 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007f0a2a3b3420 __restore_rt (/usr/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f0a29da200b raise /build/glibc-B3wQXB/glibc-2.31/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #5 0x00007f0a29d81859 abort /build/glibc-B3wQXB/glibc-2.31/stdlib/abort.c:81:7
 #6 0x000056102b76932e (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x1a7232e)
 #7 0x0000561030ba5ae6 getGridValue(llvm::Triple const&, llvm::Function*) (.isra.0) OMPIRBuilder.cpp:0:0
 #8 0x0000561030bf2e3f llvm::OpenMPIRBuilder::createTargetInit(llvm::OpenMPIRBuilder::LocationDescription const&, llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs const&) (.part.0) OMPIRBuilder.cpp:0:0
 #9 0x0000561030bfafde createOutlinedFunction(llvm::OpenMPIRBuilder&, llvm::IRBuilderBase&, llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs const&, llvm::StringRef, llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<llvm::Expected<llvm::IRBuilderBase::InsertPoint> (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)>&, llvm::function_ref<llvm::Expected<llvm::IRBuilderBase::InsertPoint> (llvm::Argument&, llvm::Value*, llvm::Value*&, llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)>&) OMPIRBuilder.cpp:0:0
#10 0x0000561030bfb9ed std::_Function_handler<llvm::Expected<llvm::Function*> (llvm::StringRef), emitTargetOutlinedFunction(llvm::OpenMPIRBuilder&, llvm::IRBuilderBase&, bool, llvm::TargetRegionEntryInfo&, llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs const&, llvm::Function*&, llvm::Constant*&, llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<llvm::Expected<llvm::IRBuilderBase::InsertPoint> (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)>&, llvm::function_ref<llvm::Expected<llvm::IRBuilderBase::InsertPoint> (llvm::Argument&, llvm::Value*, llvm::Value*&, llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)>&)::'lambda'(llvm::StringRef)>::_M_invoke(std::_Any_data const&, llvm::StringRef&&) OMPIRBuilder.cpp:0:0
#11 0x0000561030be1e56 llvm::OpenMPIRBuilder::emitTargetRegionFunction(llvm::TargetRegionEntryInfo&, std::function<llvm::Expected<llvm::Function*> (llvm::StringRef)>&, bool, llvm::Function*&, llvm::Constant*&) (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x6eeae56)
#12 0x0000561030c0baca llvm::OpenMPIRBuilder::createTarget(llvm::OpenMPIRBuilder::LocationDescription const&, bool, llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint, llvm::OpenMPIRBuilder::TargetDataInfo&, llvm::TargetRegionEntryInfo&, llvm::OpenMPIRBuilder::TargetKernelDefaultAttrs const&, llvm::OpenMPIRBuilder::TargetKernelRuntimeAttrs const&, llvm::Value*, llvm::SmallVectorImpl<llvm::Value*>&, llvm::function_ref<llvm::OpenMPIRBuilder::MapInfosTy& (llvm::IRBuilderBase::InsertPoint)>, llvm::function_ref<llvm::Expected<llvm::IRBuilderBase::InsertPoint> (llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)>, llvm::function_ref<llvm::Expected<llvm::IRBuilderBase::InsertPoint> (llvm::Argument&, llvm::Value*, llvm::Value*&, llvm::IRBuilderBase::InsertPoint, llvm::IRBuilderBase::InsertPoint)>, llvm::function_ref<llvm::Expected<llvm::Function*> (unsigned int)>, llvm::SmallVector<llvm::OpenMPIRBuilder::DependData, 2u> const&, bool) (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x6f14aca)
#13 0x000056102db66e47 convertOmpTarget(mlir::Operation&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#14 0x000056102db837ec (anonymous namespace)::OpenMPDialectLLVMIRTranslationInterface::convertOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) const OpenMPToLLVMIRTranslation.cpp:0:0
#15 0x000056102fa83b06 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x5d8cb06)
#16 0x000056102fa8ca6d mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x5d95a6d)
#17 0x000056102fa8ef45 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x5d97f45)
#18 0x000056102fa8f930 mlir::LLVM::ModuleTranslation::convertFunctions() (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x5d98930)
#19 0x000056102fa9ae9c mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef, bool) (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x5da3e9c)
#20 0x000056102bb3d6ff Fortran::frontend::CodeGenAction::generateLLVMIR() (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x1e466ff)
#21 0x000056102bb41538 Fortran::frontend::CodeGenAction::executeAction() (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x1e4a538)
#22 0x000056102b83d640 Fortran::frontend::FrontendAction::execute() (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x1b46640)
#23 0x000056102b8272eb Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x1b302eb)
#24 0x000056102b8490af Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x1b520af)
#25 0x000056102b1dc530 fc1_main(llvm::ArrayRef<char const*>, char const*) (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x14e5530)
#26 0x000056102b0b3072 main (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x13bc072)
#27 0x00007f0a29d83083 __libc_start_main /build/glibc-B3wQXB/glibc-2.31/csu/../csu/libc-start.c:342:3
#28 0x000056102b1db34e _start (/home/amd/llvm-flang-project/community-llvm-flang/community_install/bin/flang+0x14e434e)
flang-22: error: unable to execute command: Aborted (core dumped)
flang-22: error: flang frontend command failed due to signal (use -v to see invocation)
flang version 22.0.0git ([email protected]:kaviya2510/llvm-project.git 148e099b39a25ea4336faeef485c53819b269fc2)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/amd/llvm-flang-project/community-llvm-flang/community_install/bin
Build config: +assertions
flang-22: note: diagnostic msg:
********************
 
PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
flang-22: note: diagnostic msg: /tmp/test-63ee30
flang-22: note: diagnostic msg: /tmp/test-0e14c4
flang-22: note: diagnostic msg: /tmp/test-63ee30.sh
flang-22: note: diagnostic msg:
 
********************
```
 
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to