Issue 91058
Summary Crash at `CGDebugInfo.cpp:671: Unexpected builtin type`
Labels c++20, clang:codegen, debuginfo, confirmed, crash
Assignees
Reporter Endilll
    While reducing #91006, I found the following crash (https://godbolt.org/z/q9cMs7Eez):
```
struct integral_constant {
 constexpr operator int() {
    return 0;
  }
};

template < typename _Tp, _Tp... >
struct integer_sequence {};

int main() {
 []< int... i >(integer_sequence<int, i... >) {
    (
      [](auto k, integer_sequence<int>) {
        using lambda_type = decltype([] -> decltype(k) { return {}; });
        lambda_type a; // the only difference from #91006
      }(integral_constant{}, __make_integer_seq<integer_sequence, int, i >{}),
      ...
    );
 }(integer_sequence<int, 0 >{});
}
```
```
Unexpected builtin type
UNREACHABLE executed at /root/llvm-project/clang/lib/CodeGen/CGDebugInfo.cpp:671!

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++23 <source>
1.	<eof> parser at end of file
2.	Per-file LLVM IR generation
3.	<source>:13:7: Generating code for declaration 'main()::(anonymous class)::operator()(integer_sequence<int, 0>)::(anonymous class)::operator()'
 #0 0x0000000003979e88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3979e88)
 #1 0x0000000003977b6c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3977b6c)
 #2 0x00000000038c9528 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000078b0a9842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000078b0a98969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000078b0a9842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000078b0a98287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x00000000038d47ba (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38d47ba)
 #8 0x0000000003c5b672 clang::CodeGen::CGDebugInfo::CreateType(clang::BuiltinType const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c5b672)
 #9 0x0000000003c4d782 clang::CodeGen::CGDebugInfo::CreateTypeNode(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c4d782)
#10 0x0000000003c4d900 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c4d900)
#11 0x0000000003c5ab67 clang::CodeGen::CGDebugInfo::CreateType(clang::FunctionType const*, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c5ab67)
#12 0x0000000003c4d66c clang::CodeGen::CGDebugInfo::CreateTypeNode(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c4d66c)
#13 0x0000000003c4d900 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c4d900)
#14 0x0000000003c5698a clang::CodeGen::CGDebugInfo::getOrCreateInstanceMethodType(clang::QualType, clang::FunctionProtoType const*, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c5698a)
#15 0x0000000003c5f455 clang::CodeGen::CGDebugInfo::CreateCXXMemberFunction(clang::CXXMethodDecl const*, llvm::DIFile*, llvm::DIType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c5f455)
#16 0x0000000003c5fd29 clang::CodeGen::CGDebugInfo::CollectCXXMemberFunctions(clang::CXXRecordDecl const*, llvm::DIFile*, llvm::SmallVectorImpl<llvm::Metadata*>&, llvm::DIType*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c5fd29)
#17 0x0000000003c5dff2 clang::CodeGen::CGDebugInfo::CreateTypeDefinition(clang::RecordType const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c5dff2)
#18 0x0000000003c6070b clang::CodeGen::CGDebugInfo::CreateType(clang::RecordType const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c6070b)
#19 0x0000000003c4d681 clang::CodeGen::CGDebugInfo::CreateTypeNode(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c4d681)
#20 0x0000000003c4d900 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c4d900)
#21 0x0000000003c66bdb clang::CodeGen::CGDebugInfo::CreateType(clang::TypedefType const*, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c66bdb)
#22 0x0000000003c4d68f clang::CodeGen::CGDebugInfo::CreateTypeNode(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c4d68f)
#23 0x0000000003c4d900 clang::CodeGen::CGDebugInfo::getOrCreateType(clang::QualType, llvm::DIFile*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c4d900)
#24 0x0000000003c5096c clang::CodeGen::CGDebugInfo::EmitDeclare(clang::VarDecl const*, llvm::Value*, std::optional<unsigned int>, clang::CodeGen::CGBuilderTy&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3c5096c)
#25 0x00000000040891ad clang::CodeGen::CodeGenFunction::EmitAutoVarAlloca(clang::VarDecl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x40891ad)
#26 0x000000000408a48b clang::CodeGen::CodeGenFunction::EmitVarDecl(clang::VarDecl const&) (.part.0) CGDecl.cpp:0:0
#27 0x000000000408a6e6 clang::CodeGen::CodeGenFunction::EmitDecl(clang::Decl const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x408a6e6)
#28 0x0000000003caac87 clang::CodeGen::CodeGenFunction::EmitDeclStmt(clang::DeclStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3caac87)
#29 0x0000000003cc0289 clang::CodeGen::CodeGenFunction::EmitSimpleStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3cc0289)
#30 0x0000000003cb8205 clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3cb8205)
#31 0x0000000003cbfcec clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3cbfcec)
#32 0x0000000003d229da clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d229da)
#33 0x0000000003d365bc clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d365bc)
#34 0x0000000003d96602 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d96602)
#35 0x0000000003d90eb5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d90eb5)
#36 0x0000000003d9cfcd clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d9cfcd)
#37 0x0000000003d9cf20 clang::CodeGen::CodeGenModule::EmitDeferred() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d9cf20)
#38 0x0000000003d9f873 clang::CodeGen::CodeGenModule::Release() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3d9f873)
#39 0x00000000042496fe (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) ModuleBuilder.cpp:0:0
#40 0x0000000004248215 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4248215)
#41 0x0000000006284e9c clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6284e9c)
#42 0x0000000004247228 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4247228)
#43 0x00000000044c85b9 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44c85b9)
#44 0x000000000445067e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x445067e)
#45 0x00000000045af39e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x45af39e)
#46 0x0000000000c4fcec cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4fcec)
#47 0x0000000000c48f7a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#48 0x000000000428aa69 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
#49 0x00000000038c99d4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x38c99d4)
#50 0x000000000428b05f 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
#51 0x00000000042513f5 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42513f5)
#52 0x0000000004251e5d 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+++0x4251e5d)
#53 0x0000000004259be5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4259be5)
#54 0x0000000000c4d185 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc4d185)
#55 0x0000000000b2f254 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xb2f254)
#56 0x000078b0a9829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#57 0x000078b0a9829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#58 0x0000000000c48a6e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc48a6e)
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