<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/145558>145558</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
OpenMP TARGET DATA crash with IF(.FALSE.)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
kparzysz
</td>
</tr>
</table>
<pre>
A modified version of use_device_ptr-1.f90 from the gfortran test suite:
```
use iso_c_binding, only: c_ptr
implicit none (external, type)
interface
subroutine bar(x)
import
type(c_ptr), value :: x
end
end interface
type(c_ptr) :: x
!$omp target data map(alloc: x) if(.false.)
!$omp target data use_device_ptr(x) if(.false.)
call bar(x)
!$omp end target data
!$omp end target data
end
```
flang -fc1 -emit-llvm -module-dir <module-dir> -fopenmp use_device_ptr-1.f90
where "module-dir" = install_prefix/include/flang
```
#0 0x00007e68dbde3840 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/work2/kparzysz/c/org/bin/../lib/libLLVMSupport.so.21.0git+0x1e3840)
#1 0x00007e68dbde0c4f llvm::sys::RunSignalHandlers() (/work2/kparzysz/c/org/bin/../lib/libLLVMSupport.so.21.0git+0x1e0c4f)
#2 0x00007e68dbde0d9a SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00007e68db442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007e68db4969fc __pthread_kill_implementation ./nptl/pthread_kill.c:44:76
#5 0x00007e68db4969fc __pthread_kill_internal ./nptl/pthread_kill.c:78:10
#6 0x00007e68db4969fc pthread_kill ./nptl/pthread_kill.c:89:10
#7 0x00007e68db442476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007e68db4287f3 abort ./stdlib/abort.c:81:7
#9 0x00007e68db42871b _nl_load_domain ./intl/loadmsgcat.c:1177:9
#10 0x00007e68db439e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#11 0x00007e68d879e943 llvm::TargetFolder::FoldGEP(llvm::Type*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::GEPNoWrapFlags) const (/work2/kparzysz/c/org/bin/../lib/../lib/libLLVMAnalysis.so.21.0git+0x19e943)
#12 0x00007e68d1fa36cd llvm::IRBuilderBase::CreateGEP(llvm::Type*, llvm::Value*, llvm::ArrayRef<llvm::Value*>, llvm::Twine const&, llvm::GEPNoWrapFlags) (/work2/kparzysz/c/org/bin/../lib/../lib/../lib/libMLIRLLVMToLLVMIRTranslation.so.21.0git+0x266cd)
#13 0x00007e68d1fc41cb convertOperationImpl(mlir::Operation&, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) LLVMToLLVMIRTranslation.cpp:0:0
#14 0x00007e68dafc7636 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/work2/kparzysz/c/org/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.21.0git+0x2e636)
#15 0x00007e68dafd2892 mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/work2/kparzysz/c/org/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.21.0git+0x39892)
#16 0x00007e68d35cedcb inlineConvertOmpRegions(mlir::Region&, llvm::StringRef, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&, llvm::SmallVectorImpl<llvm::Value*>*) OpenMPToLLVMIRTranslation.cpp:0:0
#17 0x00007e68d35d1eb5 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
#18 0x00007e68d7fc70c0 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*) (/work2/kparzysz/c/org/bin/../lib/../lib/libLLVMFrontendOpenMP.so.21.0git+0x930c0)
#19 0x00007e68d35c4279 convertOmpTargetData(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#20 0x00007e68d35e5559 convertHostOrTargetOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#21 0x00007e68dafc7636 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/work2/kparzysz/c/org/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.21.0git+0x2e636)
#22 0x00007e68dafd2892 mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/work2/kparzysz/c/org/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.21.0git+0x39892)
#23 0x00007e68d35cedcb inlineConvertOmpRegions(mlir::Region&, llvm::StringRef, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&, llvm::SmallVectorImpl<llvm::Value*>*) OpenMPToLLVMIRTranslation.cpp:0:0
#24 0x00007e68d35d1eb5 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
#25 0x00007e68d7fc70c0 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*) (/work2/kparzysz/c/org/bin/../lib/../lib/libLLVMFrontendOpenMP.so.21.0git+0x930c0)
#26 0x00007e68d35c4279 convertOmpTargetData(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#27 0x00007e68d35e5559 convertHostOrTargetOperation(mlir::Operation*, llvm::IRBuilderBase&, mlir::LLVM::ModuleTranslation&) OpenMPToLLVMIRTranslation.cpp:0:0
#28 0x00007e68dafc7636 mlir::LLVM::ModuleTranslation::convertOperation(mlir::Operation&, llvm::IRBuilderBase&, bool) (/work2/kparzysz/c/org/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.21.0git+0x2e636)
#29 0x00007e68dafd2892 mlir::LLVM::ModuleTranslation::convertBlockImpl(mlir::Block&, bool, llvm::IRBuilderBase&, bool) (/work2/kparzysz/c/org/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.21.0git+0x39892)
#30 0x00007e68dafd4126 mlir::LLVM::ModuleTranslation::convertOneFunction(mlir::LLVM::LLVMFuncOp) (/work2/kparzysz/c/org/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.21.0git+0x3b126)
#31 0x00007e68dafd4bb8 mlir::LLVM::ModuleTranslation::convertFunctions() (/work2/kparzysz/c/org/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.21.0git+0x3bbb8)
#32 0x00007e68dafdebf6 mlir::translateModuleToLLVMIR(mlir::Operation*, llvm::LLVMContext&, llvm::StringRef, bool) (/work2/kparzysz/c/org/bin/../lib/../lib/libMLIRTargetLLVMIRExport.so.21.0git+0x45bf6)
#33 0x00007e68de2e7785 Fortran::frontend::CodeGenAction::generateLLVMIR() (/work2/kparzysz/c/org/bin/../lib/libflangFrontend.so.21.0git+0x156785)
#34 0x00007e68de2ec980 Fortran::frontend::CodeGenAction::executeAction() (/work2/kparzysz/c/org/bin/../lib/libflangFrontend.so.21.0git+0x15b980)
#35 0x00007e68de2d1c11 Fortran::frontend::FrontendAction::execute() (/work2/kparzysz/c/org/bin/../lib/libflangFrontend.so.21.0git+0x140c11)
#36 0x00007e68de1b424b Fortran::frontend::CompilerInstance::executeAction(Fortran::frontend::FrontendAction&) (/work2/kparzysz/c/org/bin/../lib/libflangFrontend.so.21.0git+0x2324b)
#37 0x00007e68e047cb8e Fortran::frontend::executeCompilerInvocation(Fortran::frontend::CompilerInstance*) (/work2/kparzysz/c/org/bin/../lib/libflangFrontendTool.so.21.0git+0x4b8e)
#38 0x00006497a86c590d fc1_main(llvm::ArrayRef<char const*>, char const*) (/work/kparzysz/c/org/bin/flang+0x890d)
#39 0x00006497a86c3ce3 main (/work/kparzysz/c/org/bin/flang+0x6ce3)
#40 0x00007e68db429d90 __libc_start_call_main ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
#41 0x00007e68db429e40 call_init ./csu/../csu/libc-start.c:128:20
#42 0x00007e68db429e40 __libc_start_main ./csu/../csu/libc-start.c:379:5
#43 0x00006497a86c4205 _start (/work/kparzysz/c/org/bin/flang+0x7205)
Aborted (core dumped)
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsWl9v27jy_TTMC2FDov4_-EFN426A9tciDfb3KFDUyOENRQoUlTj76S9IyZFlu2mTNtu9iwBpKlPk4Tkz5HAYD-06vpEAKxS9Q9H7M9qbG6VXty3Vfz10f52VqnpY5bhRFa85VPgOdMeVxKrGfQdFBXecQdEavfCXdebhWqsGmxvAm1ppo6nEBjqDu54bQEGOPPcTe-OPl_cdYN6pghUllxWXG0TOsZLiAQU5ZhYZeTlvWsEZN1gqCRiRFLYGtKTCdjYPLSCSDdBcGtA1ZYC8HOOuL7XqDZeAS6oRSbdDR4wx5k2rtLEfBoB0mIxkFvOOih6wJRzkeOtGgKyQl4Os8P4cyMsPhu-Psj_ERyRUTYsN1RswuKKG4oa2iKRUCMWGviTDvEYkXdZUdLAc9ZwcO7f7KOrEaIwZFWIufEK0QvZQv_NuEL_vN-TltaBygxc18zFeQMPNQoi7BuNFo6pewKLiGqPgfPqEggu8qFULsmlPLp8B9_4GtPUy2RtJCEbBe8xlZ6gQRauh5ltE1lwy0VeAyNqxOV5fGJHAw97W8zwvgTitygqCNPSw5Tq4qnvohocvmkvz1VB2e62te0k6ddL0vlCd0UAbRGK7Rrg0zt0kRWR9r_QtQWS92ziIrBkia6U3iKxLLhFZL5eIrAUvh98fP_756Wvf2jW47NSS-Etvww0i77yt7wiOTkQk8A_oeyysT9G_6uVXvpFU_EFlJUB3jtrrMLQcJobkkGGVUTzjgkjq7HWOO77hslaFQSR3W03xyj1m44huydoWBbnn_g0TBLMJ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