Closed ericniebler closed 4 months ago
@llvm/issue-subscribers-clang-codegen
Author: Eric Niebler (ericniebler)
The issue can be reproduced on godbolt with an asserts build but is too large for the short link generator to handle it.
Confirmed on 19.0 and 18.1.0: https://godbolt.org/z/qaxGa7ocs Appears to be a regression in Clang 15. It also reminds me of #88077 Reduced by me and C-Reduce:
struct get_scheduler_t {
void operator()();
};
template <class _Ty>
struct __box {
[[no_unique_address]] _Ty __value;
};
struct __sexpr {
__box<get_scheduler_t> __impl_;
};
void get_scheduler_t::operator()() {
__sexpr{};
}
Clang 19.0 stack trace:
<source>:15:3: warning: expression result unused [-Wunused-value]
15 | __sexpr{};
| ^ ~~
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 -std=c++20 <source>
1. <eof> parser at end of file
2. <source>:14:23: LLVM IR generation of declaration 'get_scheduler_t::operator()'
3. <source>:14:23: Generating code for declaration 'get_scheduler_t::operator()'
#0 0x0000000003979978 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3979978)
#1 0x000000000397765c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x397765c)
#2 0x00000000038c9018 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007943ecc42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00000000032c361e llvm::Instruction::eraseFromParent() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x32c361e)
#5 0x00000000040e58d1 (anonymous namespace)::AggExprEmitter::VisitCXXParenListOrInitListExpr(clang::Expr*, llvm::ArrayRef<clang::Expr*>, clang::FieldDecl*, clang::Expr*) CGExprAgg.cpp:0:0
#6 0x00000000040df90c (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#7 0x00000000040e6674 (anonymous namespace)::AggExprEmitter::VisitCastExpr(clang::CastExpr*) CGExprAgg.cpp:0:0
#8 0x00000000040df141 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) CGExprAgg.cpp:0:0
#9 0x00000000040e012f clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40e012f)
#10 0x00000000040af9b5 clang::CodeGen::CodeGenFunction::EmitAnyExpr(clang::Expr const*, clang::CodeGen::AggValueSlot, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40af9b5)
#11 0x00000000040d1a0d clang::CodeGen::CodeGenFunction::EmitIgnoredExpr(clang::Expr const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40d1a0d)
#12 0x0000000003cb7dd5 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3cb7dd5)
#13 0x0000000003cbf84c clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3cbf84c)
#14 0x0000000003d2253a clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d2253a)
#15 0x0000000003d3611c clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d3611c)
#16 0x0000000003d96162 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d96162)
#17 0x0000000003d90a15 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d90a15)
#18 0x0000000003d91033 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d91033)
#19 0x0000000003d9b5f3 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#20 0x0000000004249b76 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#21 0x000000000423a238 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x423a238)
#22 0x0000000006285264 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6285264)
#23 0x0000000004246e08 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4246e08)
#24 0x00000000044c8199 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44c8199)
#25 0x000000000445025e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x445025e)
#26 0x00000000045aef3e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45aef3e)
#27 0x0000000000c4fdec cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4fdec)
#28 0x0000000000c4907a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#29 0x000000000428a649 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
#30 0x00000000038c94c4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38c94c4)
#31 0x000000000428ac3f 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
#32 0x0000000004250fd5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4250fd5)
#33 0x0000000004251a3d 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+++0x4251a3d)
#34 0x00000000042597c5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42597c5)
#35 0x0000000000c4d285 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4d285)
#36 0x0000000000b2f354 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb2f354)
#37 0x00007943ecc29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#38 0x00007943ecc29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#39 0x0000000000c48b6e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc48b6e)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139
@llvm/issue-subscribers-c-20
Author: Eric Niebler (ericniebler)
@Endilll looks fixed on latest trunk: https://godbolt.org/z/fqaYcTeP6