OpenMP compilation assertion hit in CGStmtOpenMP.cpp
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
[godbolt link](https://godbolt.org/#g:!((g:!((g:!((h:codeEditor,i:(filename:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,selection:(endColumn:1,endLineNumber:13,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:13,startColumn:1,startLineNumber:1),source:'struct+S+%7B%0A++int+len%3B%0A%7D%3B%0A%0Avoid+foo()+%7B%0A++struct+S+s1%3B%0A%0A%23pragma+omp+target+map(tofrom+:+s1)%0A++%7B%0A++++s1.len+%3D+0%3B%0A++%7D%0A%7D%0A'),l:'5',n:'0',o:'C%2B%2B+source+%231',t:'0')),k:33.333333333333336,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:compiler,i:(compiler:clang_assertions_trunk,filters:(b:'0',binary:'1',binaryObject:'1',commentOnly:'0',debugCalls:'1',demangle:'0',directives:'0',execute:'1',intel:'0',libraryCode:'0',trim:'1',verboseDemangling:'0'),flagsViewOpen:'1',fontScale:14,fontUsePx:'0',j:1,lang:c%2B%2B,libs:!(),options:'-fopenmp+-g+-fopenmp-targets%3Dx86_64-unknown-linux-gnu',overrides:!(),selection:(endColumn:1,endLineNumber:1,positionColumn:1,positionLineNumber:1,selectionStartColumn:1,selectionStartLineNumber:1,startColumn:1,startLineNumber:1),source:1),l:'5',n:'0',o:'+x86-64+clang+(assertions+trunk)+(Editor+%231)',t:'0')),k:33.333333333333336,l:'4',n:'0',o:'',s:0,t:'0'),(g:!((h:output,i:(compilerName:'x86-64+clang+(assertions+trunk)',editorid:1,fontScale:14,fontUsePx:'0',j:1,wrap:'1'),l:'5',n:'0',o:'Output+of+x86-64+clang+(assertions+trunk)+(Compiler+%231)',t:'0')),k:33.33333333333333,l:'4',n:'0',o:'',s:0,t:'0')),l:'2',n:'0',o:'',t:'0')),version:4)
```c++
struct S {
int len;
};
void foo() {
struct S s1;
#pragma omp target map(tofrom : s1)
{
s1.len = 0;
}
}
```
```
clang -fopenmp -g -fopenmp-targets=x86_64-unknown-linux-gnu file.c
```
```
clang-23: /root/llvm-project/llvm/tools/clang/lib/CodeGen/CGStmtOpenMP.cpp:990: llvm::Function* clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunctionAggregate(const clang::CapturedStmt&, const clang::OMPExecutableDirective&): Assertion `RD->getNumFields() + 1 == F->getNumOperands() && "Argument count mismatch"' 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: /cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23 -cc1 -triple x86_64-unknown-linux-gnu -aux-triple x86_64-unknown-linux-gnu -S -disable-free -clear-ast-before-backend -main-file-name example.cpp -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -fno-verbose-asm -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debug-info-kind=constructor -dwarf-version=5 -debugger-tuning=gdb -fdebug-compilation-dir=/app -fcoverage-compilation-dir=/app -resource-dir /cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/lib/clang/23 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.1/../../../../include/c++/16.0.1 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.1/../../../../include/c++/16.0.1/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.1/../../../../include/c++/16.0.1/backward -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.1/../../../../include/c++/16.0.1 -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.1/../../../../include/c++/16.0.1/x86_64-linux-gnu -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.1/../../../../include/c++/16.0.1/backward -internal-isystem /cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/lib/clang/23/include/llvm_libc_wrappers -internal-isystem /cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/lib/clang/23/include -internal-isystem /cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/../include/x86_64-unknown-linux-gnu -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.1/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -internal-isystem /cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/lib/clang/23/include -internal-isystem /cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/../include/x86_64-unknown-linux-gnu -internal-isystem /usr/local/include -internal-isystem /opt/compiler-explorer/gcc-snapshot/lib/gcc/x86_64-linux-gnu/16.0.1/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdeprecated-macro -ferror-limit 19 -fvisibility=protected -fopenmp --offload-new-driver -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -fcolor-diagnostics -mllvm --x86-asm-syntax=intel -fopenmp-is-target-device -fopenmp-host-ir-file-path /tmp/example-18a562.bc -faddrsig -fdwarf2-cfi-asm -o /tmp/example-1c4802.s -x c++
1. parser at end of file
2. :5:6: LLVM IR generation of declaration 'foo'
#0 0x00000000044e7908 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x44e7908)
#1 0x00000000044e4734 llvm::sys::RunSignalHandlers() (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x44e4734)
#2 0x00000000044e48aa SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
#3 0x00000000044e4948 SignalHandlerTerminate(int, siginfo_t*, void*) Signals.cpp:0:0
#4 0x00007d3706e42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#5 0x00007d3706e969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#6 0x00007d3706e42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#7 0x00007d3706e287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#8 0x00007d3706e2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#9 0x00007d3706e39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#10 0x0000000004bc4cce clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunctionAggregate(clang::CapturedStmt const&, clang::OMPExecutableDirective const&) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x4bc4cce)
#11 0x0000000004ae548f std::_Function_handler (llvm::StringRef), clang::CodeGen::CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(clang::OMPExecutableDirective const&, llvm::StringRef, llvm::Function*&, llvm::Constant*&, bool, clang::CodeGen::RegionCodeGenTy const&)::'lambda'(llvm::StringRef)>::_M_invoke(std::_Any_data const&, llvm::StringRef&&) CGOpenMPRuntime.cpp:0:0
#12 0x0000000008911a97 llvm::OpenMPIRBuilder::emitTargetRegionFunction(llvm::TargetRegionEntryInfo&, std::function (llvm::StringRef)>&, bool, llvm::Function*&, llvm::Constant*&) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x8911a97)
#13 0x0000000004ac460b clang::CodeGen::CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(clang::OMPExecutableDirective const&, llvm::StringRef, llvm::Function*&, llvm::Constant*&, bool, clang::CodeGen::RegionCodeGenTy const&) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x4ac460b)
#14 0x0000000004ac16a6 clang::CodeGen::CGOpenMPRuntime::emitTargetOutlinedFunction(clang::OMPExecutableDirective const&, llvm::StringRef, llvm::Function*&, llvm::Constant*&, bool, clang::CodeGen::RegionCodeGenTy const&) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x4ac16a6)
#15 0x0000000004b7b155 clang::CodeGen::CodeGenFunction::EmitOMPTargetDeviceFunction(clang::CodeGen::CodeGenModule&, llvm::StringRef, clang::OMPTargetDirective const&) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x4b7b155)
#16 0x0000000004af7660 clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt const*, llvm::StringRef) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x4af7660)
#17 0x0000000004af72a6 clang::CodeGen::CGOpenMPRuntime::scanForTargetRegionsFunctions(clang::Stmt const*, llvm::StringRef) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x4af72a6)
#18 0x0000000004af7a05 clang::CodeGen::CGOpenMPRuntime::emitTargetFunctions(clang::GlobalDecl) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x4af7a05)
#19 0x0000000004c581cc clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x4c581cc)
#20 0x0000000004c64bc3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#21 0x0000000004fe0489 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#22 0x0000000004fd1884 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x4fd1884)
#23 0x0000000006d7f254 clang::ParseAST(clang::Sema&, bool, bool) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x6d7f254)
#24 0x0000000004fde248 clang::CodeGenAction::ExecuteAction() (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x4fde248)
#25 0x00000000052f84e5 clang::FrontendAction::Execute() (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x52f84e5)
#26 0x0000000005276bde clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x5276bde)
#27 0x00000000053f604d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0x53f604d)
#28 0x0000000000de4b12 cc1_main(llvm::ArrayRef, char const*, void*) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0xde4b12)
#29 0x0000000000ddb44a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#30 0x0000000000ddf87e clang_main(int, char**, llvm::ToolContext const&) (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0xddf87e)
#31 0x0000000000c983da main (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0xc983da)
#32 0x00007d3706e29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#33 0x00007d3706e29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#34 0x0000000000ddaee5 _start (/cefs/ec/ec54381af8467f5a8512dc49_clang-assertions-trunk-20260325/bin/clang-23+0xddaee5)
clang++: error: unable to execute command: Aborted (core dumped)
clang++: error: clang frontend command failed with exit code -2 (use -v to see invocation)
Compiler returned: 254
```
Contributor guide
Assessment
This issue has not been assessed yet.