llvm / llvm-project

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

`clangtk`: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' failed. #63521

Open wierton opened 1 year ago

wierton commented 1 year ago

The program which triggers assertion failure:

void f(float a) { asm("" : "=@ccc"(a)); }

Verification link https://gcc.godbolt.org/z/o3M9bsjK6 The output of clangtk:

clang: /root/llvm-project/llvm/include/llvm/Support/Casting.h:578: decltype(auto) llvm::cast(From*) [with To = llvm::IntegerType; From = llvm::Type]: Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"' 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 -S --gcc-toolchain=/opt/compiler-explorer/gcc-9.2.0 -fcolor-diagnostics -fno-crash-diagnostics <source>
1.  <eof> parser at end of file
2.  <source>:1:6: LLVM IR generation of declaration 'f'
3.  <source>:1:6: Generating code for declaration 'f'
 #0 0x00005572458a693f llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c5293f)
 #1 0x00005572458a46ac llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3c506ac)
 #2 0x00005572457eed98 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007f6e4dc63420 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
 #4 0x00007f6e4d73000b raise (/lib/x86_64-linux-gnu/libc.so.6+0x4300b)
 #5 0x00007f6e4d70f859 abort (/lib/x86_64-linux-gnu/libc.so.6+0x22859)
 #6 0x00007f6e4d70f729 (/lib/x86_64-linux-gnu/libc.so.6+0x22729)
 #7 0x00007f6e4d720fd6 (/lib/x86_64-linux-gnu/libc.so.6+0x33fd6)
 #8 0x00005572451145da llvm::ConstantInt::get(llvm::Type*, unsigned long, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x34c05da)
 #9 0x0000557245bbeb5d EmitAsmStores(clang::CodeGen::CodeGenFunction&, clang::AsmStmt const&, llvm::ArrayRef<llvm::Value*>, llvm::ArrayRef<llvm::Type*>, llvm::ArrayRef<llvm::Type*>, llvm::ArrayRef<clang::CodeGen::LValue>, llvm::ArrayRef<clang::QualType>, llvm::BitVector const&, llvm::BitVector const&) CGStmt.cpp:0:0
#10 0x0000557245bcc932 clang::CodeGen::CodeGenFunction::EmitAsmStmt(clang::AsmStmt const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f78932)
#11 0x0000557245bcf29b clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*, llvm::ArrayRef<clang::Attr const*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f7b29b)
#12 0x0000557245bd5a04 clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt const&, bool, clang::CodeGen::AggValueSlot) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3f81a04)
#13 0x0000557245c3599a clang::CodeGen::CodeGenFunction::EmitFunctionBody(clang::Stmt const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3fe199a)
#14 0x0000557245c495cf clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3ff55cf)
#15 0x0000557245cae539 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x405a539)
#16 0x0000557245ca94e5 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x40554e5)
#17 0x0000557245caa0b8 clang::CodeGen::CodeGenModule::EmitGlobal(clang::GlobalDecl) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x40560b8)
#18 0x0000557245cb2f03 clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) (.part.0) CodeGenModule.cpp:0:0
#19 0x0000557246b1ffe6 (anonymous namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) ModuleBuilder.cpp:0:0
#20 0x0000557246b12090 clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ebe090)
#21 0x00005572480184b4 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x63c44b4)
#22 0x0000557246b1cec8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ec8ec8)
#23 0x0000557246367799 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4713799)
#24 0x00005572462ed0e6 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x46990e6)
#25 0x000055724644beb6 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x47f7eb6)
#26 0x0000557242d4a02d cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10f602d)
#27 0x0000557242d45d2a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#28 0x000055724614d7ed 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
#29 0x00005572457ef2a0 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3b9b2a0)
#30 0x000055724614de0f 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
#31 0x0000557246114f7c clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44c0f7c)
#32 0x0000557246115a0d 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+0x44c1a0d)
#33 0x000055724611daed clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x44c9aed)
#34 0x0000557242d4828a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10f428a)
#35 0x0000557242c4e5a5 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xffa5a5)
#36 0x00007f6e4d711083 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24083)
#37 0x0000557242d40b0e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x10ecb0e)
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