<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69214>69214</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
clang: Assertion `IsRegistered && "private var already registered as private"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
connglli
</td>
</tr>
</table>
<pre>
Compiler explorer: https://godbolt.org/z/8v5v4f95r.
The following program `small.c` triggers a crash in clang-18:
``` sh
% cat small.c
void foo (int *a)
{
int i, y = 0;
{
#pragma omp master taskloop simd reduction (+:y) default(none) firstprivate(a) private (i)
for (i = 0; i < 64; i++)
y += a[i];
}
}
% clang -O0 -fopenmp-simd small.c
clang: /root/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp:961: void clang::CodeGen::CodeGenFunction::EmitOMPPrivateClause(const clang::OMPExecutableDirective&, clang::CodeGen::CodeGenFunction::OMPPrivateScope&): Assertion `IsRegistered && "private var already registered as private"' failed.
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 -mllvm --x86-asm-syntax=intel -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics -O0 -fopenmp-simd <source>
1. <eof> parser at end of file
2. <source>:1:6: LLVM IR generation of declaration 'foo'
3. <source>:1:6: Generating code for declaration 'foo'
4. <source>:4:3: LLVM IR generation of compound statement ('{}')
#0 0x000000000372f498 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372f498)
#1 0x000000000372d15c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x372d15c)
#2 0x0000000003675a78 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007fd6dd299420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
#4 0x00007fd6dcd5c00b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
#5 0x00007fd6dcd3b859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
#6 0x00007fd6dcd3b729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
#7 0x00007fd6dcd4cfd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
#8 0x0000000003a66bfc clang::CodeGen::CodeGenFunction::EmitOMPPrivateClause(clang::OMPExecutableDirective const&, clang::CodeGen::CodeGenFunction::OMPPrivateScope&) (.part.0) CGStmtOpenMP.cpp:0:0
#9 0x0000000003a87660 emitOMPSimdRegion(clang::CodeGen::CodeGenFunction&, clang::OMPLoopDirective const&, clang::CodeGen::PrePostActionTy&) CGStmtOpenMP.cpp:0:0
#10 0x0000000003a87db4 clang::CodeGen::CodeGenFunction::EmitSimpleOMPExecutableDirective(clang::OMPExecutableDirective const&)::'lambda'(clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&)::operator()(clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&) const (.isra.0) CGStmtOpenMP.cpp:0:0
#11 0x0000000003f2259d clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f2259d)
#12 0x0000000003f228c4 (anonymous namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&, clang::Stmt const*) CGOpenMPRuntime.cpp:0:0
#13 0x0000000003f1d3f0 clang::CodeGen::CGOpenMPRuntime::emitInlinedDirective(clang::CodeGen::CodeGenFunction&, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f1d3f0)
#14 0x0000000003a917b9 clang::CodeGen::CodeGenFunction::EmitSimpleOMPExecutableDirective(clang::OMPExecutableDirective const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a917b9)
#15 0x0000000003a49c2d clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a49c2d)
#16 0x0000000003a5003c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a5003c)
#17 0x0000000003a50424 clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a50424)
#18 0x0000000003a5062e clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a5062e)
#19 0x0000000003a49b35 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a49b35)
#20 0x0000000003a5003c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3a5003c)
#21 0x0000000003aaf5a6 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3aaf5a6)
#22 0x0000000003ac264a clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ac264a)
#23 0x0000000003b234a3 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b234a3)
#24 0x0000000003b1e675 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b1e675)
#25 0x0000000003b1ec3b clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b1ec3b)
#26 0x0000000003b27fa3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#27 0x000000000499dc46 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#28 0x000000000498ed08 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x498ed08)
#29 0x0000000005ea1304 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x5ea1304)
#30 0x000000000499b538 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x499b538)
#31 0x00000000041fefa9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x41fefa9)
#32 0x000000000418044e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x418044e)
#33 0x00000000042de12e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x42de12e)
#34 0x0000000000befa56 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbefa56)
#35 0x0000000000be731a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#36 0x0000000003fdc649 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
#37 0x0000000003675f24 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3675f24)
#38 0x0000000003fdcc3f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#39 0x0000000003fa4e05 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fa4e05)
#40 0x0000000003fa586d 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+0x3fa586d)
#41 0x0000000003fad795 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fad795)
#42 0x0000000000becefc clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbecefc)
#43 0x0000000000ae7091 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xae7091)
#44 0x00007fd6dcd3d083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#45 0x0000000000be6dfe _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xbe6dfe)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
```
Clang version:
```
clang version 18.0.0 (https://github.com/llvm/llvm-project.git ab737a86993bc7bf92cbb9d51f47f8825a717333)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /opt/compiler-explorer/clang-assertions-trunk/bin
Compiler returned: 0
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsWl1v2zqT_jXKDWFDor4vcuHYSbcHLRo0wdlLgyIphVuKFEgqTfbXL0jJtqjYaZLj7nvej4OcQqao4TzPDGeGH0hr1ghKL4P0Kkg3F6g3D1JdYilEwzm7qCR5vlzLtmOcKkCfOi4VVUG8Ag_GdDqIVwG8CeBNI0kluVlK1QTw5n8DeFM8po9JXaZqGYSbIFwN_94_UFBLzuVPJhrQKdko1IIgC3WLOF_iIAuBUaxpqNIAAayQfgBMAMyRaBZRYQeciAuycPgD-mFsgSnAyICdPNf4KBkBtZQggAUTBgRwhQJYjl_kV8MDAPYdC-AaPIMg3oAwiPevJr0ACGDcKdS0CMi2Ay3ShipgkP7BpeyAZi0BipIeGyaFHTOAV0G8eg5gCQitUc9NAAshBbUtNVPadIo9IkMDWFjFwPjT6btX1I5cS-Ua9_oB-7gGWeKe7UD2b_IFsGDs-BuAgvSKBenmACvINzsSNh6vlkVLOVh8C8Gilh0VbbdwyDxmXSfrDgG8UVKaAN5w_tguOiX_h2L7c-gBbzirAnizloR-osI-fbozrfnWUfH1dom7LohXZRZZUc5aO8FBvNp9M_1x0wvH7tB43TLz7evt7cDamqNeWyqxFNpMJX37env9RHFvUMXphimKDXukAcyszd814mG0Oyy7QURplV9pTdVg9yz8rL_ThlnvoAS4PhkIINxZ9xEpgLiiiDwDdeiINNi7AwxgDmrEOCXjPLr9cr26uwa6r1pmAAJV3wBFO6kMMHI-K5l56Ksllu1ol5fmYVr3VAfwBiBBABOY94QC80DHuVch_MMohKmlqFO0UxJTrSkBWvZqaLZfIq0lZshQAlQvgMaKdWZU-c4g_AOQvu320zdcAnA7zn6kmr6lwujRj2Tn_GYMOot90Bl9aYF2FOuFUb34EcCbionda7BoyE-k6kUCFg1Y2Dl_g7rOyu1N15ulBovWkgAWi6ciWyDdLvSzMOg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