<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/63943>63943</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            clang crashes: UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:251!
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          wierton
      </td>
    </tr>
</table>

<pre>
    When attempting to compile below program using command `clang-17 -fopenmp-simd small.c`, Clang crashes.
```
int a;
void b(void) {
#pragma omp target teams distribute
  for (a = 0; a < 10; a++)
 ;
}
```

The testing clang's version is (associated with commit f05b58a9468cc2990678e06bc51df56b30344807):
```
clang version 17.0.0 (https://github.com/llvm/llvm-project.git f05b58a9468cc2990678e06bc51df56b30344807)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
```

And below is clang's output copied from compiler explorer (https://gcc.godbolt.org/z/nezef7aWM):
```
No context value for inlined OpenMP region
UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CGOpenMPRuntime.cpp:251!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang -gdwarf-4 -g -o /app/output.s -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -fopenmp-simd <source>
1.      <eof> parser at end of file
2.      <source>:2:6: LLVM IR generation of declaration 'b'
3.      <source>:2:6: Generating code for declaration 'b'
 #0 0x00005596dda9ac1a llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a9ac1a)
 #1 0x00005596dda9884c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a9884c)
 #2 0x00005596dd9e7020 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007ff869980420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007ff86944d00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007ff86942c859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00005596dd9f2dba (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x39f2dba)
 #7 0x00005596de1da54e (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41da54e)
 #8 0x00005596de1116e8 clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41116e8)
 #9 0x00005596de10d1f6 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x410d1f6)
#10 0x00005596de10d5a0 clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x410d5a0)
#11 0x00005596dddab143 clang::CodeGen::CodeGenFunction::EmitSimpleOMPExecutableDirective(clang::OMPExecutableDirective const&)::'lambda'(clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&)::operator()(clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&) const CGStmtOpenMP.cpp:0:0
#12 0x00005596de1e4df0 clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41e4df0)
#13 0x00005596de1e50ee (anonymous namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&, clang::Stmt const*) CGOpenMPRuntime.cpp:0:0
#14 0x00005596de1de837 clang::CodeGen::CGOpenMPRuntime::emitInlinedDirective(clang::CodeGen::CodeGenFunction&, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41de837)
#15 0x00005596dddb42dc clang::CodeGen::CodeGenFunction::EmitSimpleOMPExecutableDirective(clang::OMPExecutableDirective const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3db42dc)
#16 0x00005596ddd727a3 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3d727a3)
#17 0x00005596ddd767ec clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3d767ec)
#18 0x00005596dddcf818 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dcf818)
#19 0x00005596ddde072b clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3de072b)
#20 0x00005596dde372dc clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e372dc)
#21 0x00005596dde33345 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e33345)
#22 0x00005596dde33863 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e33863)
#23 0x00005596dde3ae63 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.8518) CodeGenModule.cpp:0:0
#24 0x00005596deb6a260 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#25 0x00005596deb5daee clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b5daee)
#26 0x00005596dfe3a214 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5e3a214)
#27 0x00005596deb67560 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b67560)
#28 0x00005596de4892e9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44892e9)
#29 0x00005596de41dc42 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x441dc42)
#30 0x00005596de560c9f clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4560c9f)
#31 0x00005596db222cc3 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x1222cc3)
#32 0x00005596db21ade8 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#33 0x00005596de2912f9 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#34 0x00005596dd9e74a5 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x39e74a5)
#35 0x00005596de293eee clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4293eee)
#36 0x00005596de26060b clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x426060b)
#37 0x00005596de2611e3 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42611e3)
#38 0x00005596de269fd6 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4269fd6)
#39 0x00005596db220a8e clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x1220a8e)
#40 0x00005596db151cb1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x1151cb1)
#41 0x00007ff86942e083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#42 0x00005596db21a4da _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x121a4da)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl9T5DYS_zTmRTVTtvxn7AcehgE2m9vdUMAlj1Oy3B50a0suSWYhn_5KkgcsM0OAOLlUXRXJeiS5u38_tbpbsohSbMcBToP0LEjPT0iv74Q8_cFAasFPSlE9nv52BxwRraHtNOM7pAWiou1YA6iERvxAnRQ7SVrUK9NNRdsSXqEgC2lD-G4RrdCiFh3wtlso1lZItaRpljTIwgBv0MYMQlQSdQdqGYTnQbg2Xe7P_mRcIxLEZ-7XvWAVKgOcm4cAFyhYDT0BjjtJdi1Bou2QJnIHGmkgrUIVU1qystfghiJUC4kCnBMUxOcoDOIzZB43KHLPAT6zf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