Skip to content

[OpenMP] clang++: /root/llvm-project/llvm/tools/clang/lib/CodeGen/Address.h:229: clang::CodeGen::KnownNonNull_t clang::CodeGen::Address::isKnownNonNull() const: Assertion `isValid()' failed. #141228

Open
@k-arrows

Description

@k-arrows

Reproducer:
https://godbolt.org/z/d1h5hqc9q

struct A {
  int a;
};
#pragma omp declare reduction(+ : A : omp_out.a += omp_in.a)

void foo() {
  A a, b[2];
#pragma omp parallel
  {
#pragma omp for reduction(task, + : a, b)
    for (int i = 0; i < 5; i++)
      ;
  }
}

Backtrace:

clang++: /root/llvm-project/llvm/tools/clang/lib/CodeGen/Address.h:229: clang::CodeGen::KnownNonNull_t clang::CodeGen::Address::isKnownNonNull() const: Assertion `isValid()' 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 -fopenmp <source>
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	<source>:6:6: Generating code for declaration 'foo'
4.	<source>:9:3: LLVM IR generation of compound statement ('{}')
 #0 0x0000000003fac638 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3fac638)
 #1 0x0000000003faa2c4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3faa2c4)
 #2 0x0000000003eeeef8 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000072b3f9c42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000072b3f9c969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000072b3f9c42476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000072b3f9c287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000072b3f9c2871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000072b3f9c39e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x00000000042e5426 (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42e5426)
#10 0x000000000444518b EmitOMPAggregateInit(clang::CodeGen::CodeGenFunction&, clang::CodeGen::Address, clang::QualType, bool, clang::Expr const*, clang::OMPDeclareReductionDecl const*, clang::CodeGen::Address) CGOpenMPRuntime.cpp:0:0
#11 0x0000000004446c32 clang::CodeGen::CGOpenMPRuntime::emitTaskReductionInit(clang::CodeGen::CodeGenFunction&, clang::SourceLocation, llvm::ArrayRef<clang::Expr const*>, llvm::ArrayRef<clang::Expr const*>, clang::CodeGen::OMPTaskDataTy const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4446c32)
#12 0x00000000044b0739 clang::CodeGen::CodeGenFunction::EmitOMPReductionClauseInit(clang::OMPExecutableDirective const&, clang::CodeGen::CodeGenFunction::OMPPrivateScope&, bool) (.part.0) CGStmtOpenMP.cpp:0:0
#13 0x00000000044d03f7 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+++0x44d03f7)
#14 0x00000000044d17c5 emitWorksharingDirective(clang::CodeGen::CodeGenFunction&, clang::OMPLoopDirective const&, bool) CGStmtOpenMP.cpp:0:0
#15 0x00000000044d28b0 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
#16 0x0000000004402ca5 clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4402ca5)
#17 0x0000000004402cfe (anonymous namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&, clang::Stmt const*) CGOpenMPRuntime.cpp:0:0
#18 0x00000000043fc44f clang::CodeGen::CGOpenMPRuntime::emitInlinedDirective(clang::CodeGen::CodeGenFunction&, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43fc44f)
#19 0x00000000044d7028 emitOMPForDirective(clang::OMPLoopDirective const&, clang::CodeGen::CodeGenFunction&, clang::CodeGen::CodeGenModule&, bool) CGStmtOpenMP.cpp:0:0
#20 0x000000000448d80b clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x448d80b)
#21 0x000000000449503c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x449503c)
#22 0x000000000449544d clang::CodeGen::CodeGenFunction::EmitCompoundStmt(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x449544d)
#23 0x0000000004495615 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4495615)
#24 0x000000000448d025 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x448d025)
#25 0x00000000044d48b2 void clang::CodeGen::RegionCodeGenTy::CallbackFn<clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective(clang::OMPParallelDirective const&)::'lambda2'(clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&)>(long, clang::CodeGen::CodeGenFunction&, clang::CodeGen::PrePostActionTy&) CGStmtOpenMP.cpp:0:0
#26 0x0000000004402ca5 clang::CodeGen::RegionCodeGenTy::operator()(clang::CodeGen::CodeGenFunction&) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4402ca5)
#27 0x0000000004402cfe (anonymous namespace)::CGOpenMPRegionInfo::EmitBody(clang::CodeGen::CodeGenFunction&, clang::Stmt const*) CGOpenMPRuntime.cpp:0:0
#28 0x00000000044e7103 clang::CodeGen::CodeGenFunction::GenerateOpenMPCapturedStmtFunction(clang::CapturedStmt const&, clang::SourceLocation) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44e7103)
#29 0x000000000441ac53 emitParallelOrTeamsOutlinedFunction(clang::CodeGen::CodeGenModule&, clang::OMPExecutableDirective const&, clang::CapturedStmt const*, clang::VarDecl const*, llvm::omp::Directive, llvm::StringRef, clang::CodeGen::RegionCodeGenTy const&) CGOpenMPRuntime.cpp:0:0
#30 0x000000000441b051 clang::CodeGen::CGOpenMPRuntime::emitParallelOutlinedFunction(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&, clang::VarDecl const*, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x441b051)
#31 0x00000000044ba970 emitCommonOMPParallelDirective(clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&, llvm::omp::Directive, clang::CodeGen::RegionCodeGenTy const&, llvm::function_ref<void (clang::CodeGen::CodeGenFunction&, clang::OMPExecutableDirective const&, llvm::SmallVectorImpl<llvm::Value*>&)> const&) CGStmtOpenMP.cpp:0:0
#32 0x00000000044d86ca clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective(clang::OMPParallelDirective const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44d86ca)
#33 0x000000000448d49b clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x448d49b)
#34 0x000000000449503c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x449503c)
#35 0x00000000044fb1f6 clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44fb1f6)
#36 0x000000000450e63b clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x450e63b)
#37 0x00000000045784ad clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45784ad)
#38 0x0000000004573664 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4573664)
#39 0x000000000457fe2c clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x457fe2c)
#40 0x00000000045823b3 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45823b3)
#41 0x000000000495d6ce (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#42 0x0000000004959b05 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4959b05)
#43 0x000000000664a7fc clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x664a7fc)
#44 0x000000000495a298 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x495a298)
#45 0x0000000004c52cf5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4c52cf5)
#46 0x0000000004bd10fe clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4bd10fe)
#47 0x0000000004d44d19 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4d44d19)
#48 0x0000000000dae7af cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdae7af)
#49 0x0000000000da53ca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#50 0x00000000049c13a9 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
#51 0x0000000003eef394 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3eef394)
#52 0x00000000049c19bf 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
#53 0x000000000498378d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x498378d)
#54 0x000000000498481e 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+++0x498481e)
#55 0x000000000498cb05 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x498cb05)
#56 0x0000000000daacbf clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdaacbf)
#57 0x0000000000c304c4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc304c4)
#58 0x000072b3f9c29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#59 0x000072b3f9c29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#60 0x0000000000da4e75 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xda4e75)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:codegenIR generation bugs: mangling, exceptions, etc.clang:openmpOpenMP related changes to ClangcrashPrefer [crash-on-valid] or [crash-on-invalid]

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions