Issue 153987
Summary [clang][OpenMP][bytecode] Assertion `!LocalDeclMap.count(VD) && "Decl already exists in LocalDeclMap!"' failed.
Labels clang:codegen, clang:openmp, clang:bytecode
Assignees
Reporter k-arrows
    Reproducer:
https://godbolt.org/z/cTGfvafds
```cpp
void foo() {
#pragma omp for collapse(2)
  for (int i = ({float a = 0;a; }); i < 10; i++)
    for (int j = i; j < 10 + i; j++)
 ;
}
```

Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/CodeGen/CodeGenFunction.h:5373: void clang::CodeGen::CodeGenFunction::setAddrOfLocalVar(const clang::VarDecl*, clang::CodeGen::Address): Assertion `!LocalDeclMap.count(VD) && "Decl already exists in LocalDeclMap!"' 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 -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fexperimental-new-constant-interpreter -fopenmp <source>
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	<source>:1:6: Generating code for declaration 'foo'
4.	<source>:3:17: LLVM IR generation of compound statement ('{}')
 #0 0x0000000004026d28 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4026d28)
 #1 0x0000000004024154 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4024154)
 #2 0x0000000003f68988 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000077d652242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000077d6522969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000077d652242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000077d6522287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000077d65222871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000077d652239e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x000000000491e776 clang::CodeGen::CodeGenFunction::setAddrOfLocalVar(clang::VarDecl const*, clang::CodeGen::Address) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x491e776)
#10 0x0000000004922617 clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(clang::VarDecl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4922617)
#11 0x0000000004926bbb clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#12 0x00000000049273d7 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49273d7)
#13 0x00000000044ecaec clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44ecaec)
#14 0x0000000004502a08 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4502a08)
#15 0x00000000044fa361 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44fa361)
#16 0x00000000045024fc clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45024fc)
#17 0x000000000450290d clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x450290d)
#18 0x00000000043d06a6 (anonymous namespace)::ScalarExprEmitter::VisitStmtExpr(clang::StmtExpr const*) (.isra.0) CGExprScalar.cpp:0:0
#19 0x00000000043e68e4 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#20 0x00000000043e85fb (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#21 0x00000000043ee262 (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#22 0x00000000043e67d1 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#23 0x00000000043e85fb (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#24 0x00000000043e679e clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#25 0x00000000043f5ced clang::CodeGen::CodeGenFunction::EmitPromotedScalarExpr(clang::Expr const*, clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43f5ced)
#26 0x00000000043f649e (anonymous namespace)::ScalarExprEmitter::EmitBinOps(clang::BinaryOperator const*, clang::QualType) CGExprScalar.cpp:0:0
#27 0x00000000043e77d9 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#28 0x00000000043e85fb (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#29 0x00000000043e679e clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#30 0x00000000043eab7c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43eab7c)
#31 0x0000000004350eae clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4350eae)
#32 0x0000000004381831 clang::CodeGen::CodeGenFunction::EmitBinaryOperatorLValue(clang::BinaryOperator const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4381831)
#33 0x0000000004386053 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4386053)
#34 0x00000000043864a7 void llvm::function_ref<void ()>::callback_fn<clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*, clang::CodeGen::KnownNonNull_t)::'lambda'()>(long) CGExpr.cpp:0:0
#35 0x0000000007fa93a1 clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7fa93a1)
#36 0x0000000004352223 clang::CodeGen::CodeGenFunction::EmitLValue(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4352223)
#37 0x000000000437e9db clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x437e9db)
#38 0x00000000043e79e5 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#39 0x00000000043e85fb (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#40 0x00000000043e679e clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#41 0x00000000043eab7c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43eab7c)
#42 0x0000000004918281 clang::CodeGen::CodeGenFunction::EmitScalarInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4918281)
#43 0x000000000491a054 clang::CodeGen::CodeGenFunction::EmitExprAsInit(clang::Expr const*, clang::ValueDecl const*, clang::CodeGen::LValue, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x491a054)
#44 0x0000000004926550 clang::CodeGen::CodeGenFunction::EmitAutoVarInit(clang::CodeGen::CodeGenFunction::AutoVarEmission const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4926550)
#45 0x0000000004926bc6 clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#46 0x00000000045350f3 (anonymous namespace)::OMPLoopScope::emitPreInitStmt(clang::CodeGen::CodeGenFunction&, clang::OMPLoopBasedDirective const&) (.isra.0) CGStmtOpenMP.cpp:0:0
#47 0x000000000453d88d clang::CodeGen::CodeGenFunction::EmitOMPWorksharingLoop(clang::OMPLoopDirective const&, clang::Expr*, llvm::function_ref<std::pair<clang::CodeGen::LValue, clang::CodeGen::LValue> (clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&)> const&, llvm::function_ref<std::pair<llvm::Value*, llvm::Value*> (clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&, clang::CodeGen::Address, clang::CodeGen::Address)> const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x453d88d)
#48 0x000000000453f0b5 emitWorksharingDirective(clang::CodeGen::CodeGenFunction&, clang::OMPLoopDirective const&, bool) CGStmtOpenMP.cpp:0:0
#49 0x000000000453ff70 void clang::CodeGen::RegionCodeGenTy::CallbackFn<emitOMPForDirective(clang::OMPLoopDirective const&, clang::CodeGen::CodeGenFunction&, clang::CodeGen::CodeGenModule&, bool)::'lambda'(clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&)>(long, clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&) CGStmtOpenMP.cpp:0:0
#50 0x000000000446ce45 clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x446ce45)
#51 0x000000000446d0ce (anonymous namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&, clang::Stmt const*) CGOpenMPRuntime.cpp:0:0
#52 0x00000000044661af clang::CodeGen::CGOpenMPRuntime::emitInlinedDirective(clang::CodeGen::CodeGenFunction&, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44661af)
#53 0x0000000004544798 emitOMPForDirective(clang::OMPLoopDirective const&, clang::CodeGen::CodeGenFunction&, clang::CodeGen::CodeGenModule&, bool) CGStmtOpenMP.cpp:0:0
#54 0x00000000044fab3b clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44fab3b)
#55 0x00000000045024fc clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45024fc)
#56 0x00000000045699ce clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45699ce)
#57 0x000000000457b674 clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x457b674)
#58 0x00000000045e6aad clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45e6aad)
#59 0x00000000045e1a84 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45e1a84)
#60 0x00000000045ee3fc clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45ee3fc)
#61 0x00000000045f0983 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45f0983)
#62 0x00000000049cc38e (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#63 0x00000000049c8585 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49c8585)
#64 0x00000000066d781c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66d781c)
#65 0x00000000049c8d28 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49c8d28)
#66 0x0000000004cbcd15 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4cbcd15)
#67 0x0000000004c38f6e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c38f6e)
#68 0x0000000004dae5f1 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4dae5f1)
#69 0x0000000000db0c0f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdb0c0f)
#70 0x0000000000da786a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#71 0x0000000004a30739 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
#72 0x0000000003f68e24 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3f68e24)
#73 0x0000000004a30d4f 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
#74 0x00000000049f2fbd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49f2fbd)
#75 0x00000000049f404e 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+++0x49f404e)
#76 0x00000000049fbae5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x49fbae5)
#77 0x0000000000dad0c5 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdad0c5)
#78 0x0000000000c61054 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc61054)
#79 0x000077d652229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#80 0x000077d652229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#81 0x0000000000da7315 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda7315)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to