llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.61k stars 11.82k forks source link

Assertion triggered because of VLA #46236

Open rofirrim opened 4 years ago

rofirrim commented 4 years ago
Bugzilla Link 46892
Version unspecified
OS Linux

Extended Description

Hi all,

the following testcase

// -- omp.c void bar(int a, int b, int (*M)[b]) {

pragma omp task firstprivate(M)

  {}

} // -- end omp.c

causes an assert in builds with assertions enabled.

We have not observed miscompilations caused by this in builds without assertions enabled, though.

DeclRefExpr for Decl not entered in LocalDeclMap? UNREACHABLE executed at /compiler/llvm-mono/clang/lib/CodeGen/CGExpr.cpp:2753! PLEASE submit a bug report to mailto:pm-tools@bsc.es and include the crash backtrace, preprocessed source, and associated run script. Stack dump:

  1. Program arguments: /compiler/llvm-mono-bld/bin/clang-11 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -main-file-name omp.c -mrelocation-model static -mthread-model posix -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -dwarf-column-info -fno-split-dwarf-inlining -debugger-tuning=gdb -resource-dir /compiler/llvm-mono-bld/lib/clang/11.0.0 -internal-isystem /usr/local/include -internal-isystem /compiler/llvm-mono-bld/lib/clang/11.0.0/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /compiler/tmp/release -ferror-limit 19 -fopenmp -fgnuc-version=4.2.1 -fcolor-diagnostics -faddrsig -o /tmp/omp-7cf697.o -x c omp.c
  2. parser at end of file
  3. omp.c:1:6: LLVM IR generation of declaration 'bar'
  4. omp.c:1:6: Generating code for declaration 'bar'

Kind regards,

wheatman commented 1 year ago

confirming with current trunk(ef888bc67c726deb8c74ea32e7c8c9ace756b667) https://godbolt.org/z/WeEdE9Pne code

// compile with -fopenmp
void bar(int a, int b, int (*M)[b]) {
      #pragma omp task firstprivate(M)
      {}
  }

dump

DeclRefExpr for Decl not entered in LocalDeclMap?
UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CGExpr.cpp:2855!
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-snapshot -fcolor-diagnostics -fno-crash-diagnostics -fopenmp <source>
1.  <eof> parser at end of file
2.  Per-file LLVM IR generation
3.  <source>:2:6: Generating code for declaration 'bar'
 #0 0x000000000367eca8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x367eca8)
 #1 0x000000000367cb2c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x367cb2c)
 #2 0x00000000035c8568 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007fe9ede05420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007fe9ed8c800b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007fe9ed8a7859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00000000035d381a (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35d381a)
 #7 0x0000000003d83e88 clang::CodeGen::CodeGenFunction::EmitDeclRefLValue(clang::DeclRefExpr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d83e88)
 #8 0x0000000003d7f8f1 clang::CodeGen::CodeGenFunction::EmitLValueHelper(clang::Expr const*, clang::CodeGen::KnownNonNull_t) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d7f8f1)
 #9 0x0000000003d89fa2 clang::CodeGen::CodeGenFunction::EmitCheckedLValue(clang::Expr const*, clang::CodeGen::CodeGenFunction::TypeCheckKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d89fa2)
#10 0x0000000003dd4470 (anonymous namespace)::ScalarExprEmitter::EmitLoadOfLValue(clang::Expr const*) CGExprScalar.cpp:0:0
#11 0x0000000003dcd8b5 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#12 0x0000000003dcdb0b (anonymous namespace)::ScalarExprEmitter::Visit(clang::Expr*) CGExprScalar.cpp:0:0
#13 0x0000000003dd02cb (anonymous namespace)::ScalarExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprScalar.cpp:0:0
#14 0x0000000003dcc0d7 clang::StmtVisitorBase<std::add_pointer, (anonymous namespace)::ScalarExprEmitter, llvm::Value*>::Visit(clang::Stmt*) CGExprScalar.cpp:0:0
#15 0x0000000003dd3e6c clang::CodeGen::CodeGenFunction::EmitScalarExpr(clang::Expr const*, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3dd3e6c)
#16 0x0000000003a029fa clang::CodeGen::CodeGenFunction::EmitVariablyModifiedType(clang::QualType) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a029fa)
#17 0x0000000003a074fc clang::CodeGen::CodeGenFunction::StartFunction(clang::GlobalDecl, clang::QualType, llvm::Function*, clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::FunctionArgList const&, clang::SourceLocation, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a074fc)
#18 0x0000000003eaa9cb emitTaskPrivateMappingFunction(clang::CodeGen::CodeGenModule&, clang::SourceLocation, clang::CodeGen::OMPTaskDataTy const&, clang::QualType, llvm::ArrayRef<std::pair<clang::CharUnits, (anonymous namespace)::PrivateHelpersTy>>) CGOpenMPRuntime.cpp:0:0
#19 0x0000000003eabc68 clang::CodeGen::CGOpenMPRuntime::emitTaskInit(clang::CodeGen::CodeGenFunction&, clang::SourceLocation, clang::OMPExecutableDirective const&, llvm::Function*, clang::QualType, clang::CodeGen::Address, clang::CodeGen::OMPTaskDataTy const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eabc68)
#20 0x0000000003eafe86 clang::CodeGen::CGOpenMPRuntime::emitTaskCall(clang::CodeGen::CodeGenFunction&, clang::SourceLocation, clang::OMPExecutableDirective const&, llvm::Function*, clang::QualType, clang::CodeGen::Address, clang::Expr const*, clang::CodeGen::OMPTaskDataTy const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eafe86)
#21 0x000000000399c787 void llvm::function_ref<void (clang::CodeGen::CodeGenFunction&, llvm::Function*, clang::CodeGen::OMPTaskDataTy const&)>::callback_fn<clang::CodeGen::CodeGenFunction::EmitOMPTaskDirective(clang::OMPTaskDirective const&)::'lambda0'(clang::CodeGen::CodeGenFunction&, llvm::Function*, clang::CodeGen::OMPTaskDataTy const&)>(long, clang::CodeGen::CodeGenFunction&, llvm::Function*, clang::CodeGen::OMPTaskDataTy const&) CGStmtOpenMP.cpp:0:0
#22 0x00000000039e09ed clang::CodeGen::CodeGenFunction::EmitOMPTaskBasedDirective(clang::OMPExecutableDirective const&, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, llvm::function_ref<void (clang::CodeGen::CodeGenFunction&, llvm::Function*, clang::CodeGen::OMPTaskDataTy const&)> const&, clang::CodeGen::OMPTaskDataTy&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39e09ed)
#23 0x00000000039e1cce clang::CodeGen::CodeGenFunction::EmitOMPTaskDirective(clang::OMPTaskDirective const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39e1cce)
#24 0x0000000003995a0b clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3995a0b)
#25 0x000000000399bc5c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x399bc5c)
#26 0x00000000039f9436 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x39f9436)
#27 0x0000000003a0c52a clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a0c52a)
#28 0x0000000003a6dbad clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a6dbad)
#29 0x0000000003a68d45 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a68d45)
#30 0x0000000003a73a26 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a73a26)
#31 0x0000000003a764d3 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3a764d3)
#32 0x00000000048da6da (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#33 0x00000000048d920d clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48d920d)
#34 0x0000000005d974d9 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5d974d9)
#35 0x00000000048d7f18 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48d7f18)
#36 0x000000000413f719 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x413f719)
#37 0x00000000040c36de clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40c36de)
#38 0x000000000421fdb6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x421fdb6)
#39 0x0000000000bce557 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbce557)
#40 0x0000000000bc6c0a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#41 0x0000000003f22a69 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
#42 0x00000000035c8a14 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x35c8a14)
#43 0x0000000003f2305f 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
#44 0x0000000003eeb925 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eeb925)
#45 0x0000000003eec38d 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+++0x3eec38d)
#46 0x0000000003ef42e5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3ef42e5)
#47 0x0000000000bcc7ec clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbcc7ec)
#48 0x0000000000ac59d1 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xac59d1)
#49 0x00007fe9ed8a9083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#50 0x0000000000bc66ee _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbc66ee)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
llvmbot commented 1 year ago

@llvm/issue-subscribers-clang-codegen