llvm / llvm-project

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

clang14 assert on PtrTy->isOpaqueOrPointeeTypeMatches(IRFuncTy) #54950

Open Kurkin opened 2 years ago

Kurkin commented 2 years ago

I tried to migrate to the clang14 and got the following error on link stage with thin lto

ld.gold-2.38: fatal error: LLVM gold plugin: Explicit call type does not match pointee type of callee operand (Producer: 'LLVM14.0.0' Reader: 'LLVM 14.0.0')

and this crash with full lto

(gdb) bt
#0  0x00007ffff43e8290 in llvm::Value::getContext() const () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#1  0x00007ffff432fe00 in llvm::ValueAsMetadata::get(llvm::Value*) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#2  0x00007ffff4eb63fe in llvm::MetadataLoader::MetadataLoaderImpl::parseOneMetadata(llvm::SmallVectorImpl<unsigned long>&, unsigned int, (anonymous namespace)::(anonymous namespace)::PlaceholderQueue&, llvm::StringRef, unsigned int&) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#3  0x00007ffff4eb4fb7 in llvm::MetadataLoader::MetadataLoaderImpl::parseMetadata(bool) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#4  0x00007ffff4eb2acc in llvm::MetadataLoader::parseMetadata(bool) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#5  0x00007ffff4eaae84 in (anonymous namespace)::BitcodeReader::parseFunctionBody(llvm::Function*) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#6  0x00007ffff4ea739b in (anonymous namespace)::BitcodeReader::materialize(llvm::GlobalValue*) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#7  0x00007ffff4dad265 in llvm::Module::materialize(llvm::GlobalValue*) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#8  0x00007ffff4dad230 in llvm::GlobalValue::materialize() () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#9  0x00007ffff53526ac in (anonymous namespace)::IRLinker::materialize(llvm::Value*, bool) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#10 0x00007ffff432f69e in (anonymous namespace)::Mapper::mapValue(llvm::Value const*) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#11 0x00007ffff433c610 in (anonymous namespace)::Mapper::remapInstruction(llvm::Instruction*) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#12 0x00007ffff433bd0a in (anonymous namespace)::Mapper::remapFunction(llvm::Function&) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#13 0x00007ffff432a254 in (anonymous namespace)::FlushingMapper::~FlushingMapper() () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#14 0x00007ffff4328e0a in llvm::ValueMapper::mapValue(llvm::Value const&) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#15 0x00007ffff4bc0fc4 in llvm::IRMover::move(std::unique_ptr<llvm::Module, std::default_delete<llvm::Module> >, llvm::ArrayRef<llvm::GlobalValue*>, std::function<void (llvm::GlobalValue&, std::function<void (llvm::GlobalValue&)>)>, bool) () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#16 0x00007ffff4e2ebb5 in llvm::lto::LTO::linkRegularLTO(llvm::lto::LTO::RegularLTOState::AddedModule, bool) ()
   from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#17 0x00007ffff52ebce4 in llvm::lto::LTO::runRegularLTO(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int)>) ()
   from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#18 0x00007ffff52ea903 in llvm::lto::LTO::run(std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int)>, std::function<llvm::Expected<std::function<llvm::Expected<std::unique_ptr<llvm::CachedFileStream, std::default_delete<llvm::CachedFileStream> > > (unsigned int)> > (unsigned int, llvm::StringRef)>) ()
   from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#19 0x00007ffff56a4f21 in all_symbols_read_hook() () from /export/home/dkurkin/tb2/perf.x86_64-unknown-linux/install/sysroot/opt/llvm-14/bin/../lib64/LLVMgold.so
#20 0x0000000000694167 in gold::Plugin_manager::all_symbols_read(gold::Workqueue*, gold::Task*, gold::Input_objects*, gold::Symbol_table*, gold::Dirsearch*, gold::Mapfile*, gold::Task_token**) ()
#21 0x000000000069429c in gold::Plugin_hook::run(gold::Workqueue*) ()
#22 0x00000000006e5448 in gold::Workqueue::find_and_run_task(int) ()
#23 0x00000000006e55fa in gold::Workqueue::process(int) ()
#24 0x000000000042b37d in main ()

I tried to build clang in debug and got the following assert

clang-14: /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGCall.cpp:4655: clang::CodeGen::RValue clang::CodeGen::CodeGenFunction::EmitCall(const clang::CodeGen::CGFunctionInfo &, const clang::CodeGen::CGCallee &, clang::CodeGen::ReturnValueSlot, const clang::CodeGen::CallArgList &, llvm::CallBase **, bool, clang::SourceLocation): Assertion `PtrTy->isOpaqueOrPointeeTypeMatches(IRFuncTy)' 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: /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/stage2/bin/clang-14 -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -main-file-name file.i.final.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debugger-tuning=gdb -fcoverage-compilation-dir=/export/home/dkurkin/tmp/clangcrash -resource-dir /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/stage2/lib64/clang/14.0.0 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8 -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/x86_64-redhat-linux -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/backward -internal-isystem /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/stage2/lib64/clang/14.0.0/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-redhat-linux/8/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include --std=c++17 -fdeprecated-macro -fdebug-compilation-dir=/export/home/dkurkin/tmp/clangcrash -ferror-limit 19 -fgnuc-version=4.2.1 -fcxx-exceptions -fexceptions -fcolor-diagnostics -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/file-704ec7.o -x c++ file.i.final.cpp
1.  <eof> parser at end of file
2.  Per-file LLVM IR generation
3.  file.i.final.cpp:53:3: Generating code for declaration 'SF::SF'
 #0 0x00000000035f7503 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/llvm/lib/Support/Unix/Signals.inc:565:13
 #1 0x00000000035f58f0 llvm::sys::RunSignalHandlers() /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/llvm/lib/Support/Signals.cpp:98:18
 #2 0x00000000035f786f SignalHandler(int) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/llvm/lib/Support/Unix/Signals.inc:407:1
 #3 0x00007ffff7bc2c30 __restore_rt sigaction.c:0:0
 #4 0x00007ffff68cd37f raise (/lib64/libc.so.6+0x3737f)
 #5 0x00007ffff68b7db5 abort (/lib64/libc.so.6+0x21db5)
 #6 0x00007ffff68b7c89 _nl_load_domain.cold.0 loadmsgcat.c:0:0
 #7 0x00007ffff68c5a76 .annobin___GI___assert_fail.end assert.c:0:0
 #8 0x00000000039019a6 llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, true, false, void>, false, false>::operator*() const /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/llvm/include/llvm/ADT/ilist_iterator.h:138:5
 #9 0x00000000039019a6 llvm::iplist_impl<llvm::simple_ilist<llvm::Instruction>, llvm::SymbolTableListTraits<llvm::Instruction> >::getNextNode(llvm::Instruction&) const /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/llvm/include/llvm/ADT/ilist.h:377:13
#10 0x00000000039019a6 llvm::ilist_node_with_parent<llvm::Instruction, llvm::BasicBlock>::getNextNode() /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/llvm/include/llvm/ADT/ilist_node.h:294:17
#11 0x00000000039019a6 clang::CodeGen::CodeGenFunction::EmitCall(clang::CodeGen::CGFunctionInfo const&, clang::CodeGen::CGCallee const&, clang::CodeGen::ReturnValueSlot, clang::CodeGen::CallArgList const&, llvm::CallBase**, bool, clang::SourceLocation) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGCall.cpp:4670:16
#12 0x00000000039d88a4 clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall(clang::CXXConstructorDecl const*, clang::CXXCtorType, bool, bool, clang::CodeGen::Address, clang::CodeGen::CallArgList&, clang::CodeGen::AggValueSlot::Overlap_t, clang::SourceLocation, bool) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGClass.cpp:2194:7
#13 0x00000000039d7fee clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall(clang::CXXConstructorDecl const*, clang::CXXCtorType, bool, bool, clang::CodeGen::AggValueSlot, clang::CXXConstructExpr const*) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGClass.cpp:0:3
#14 0x0000000003b60b4e clang::CodeGen::CodeGenFunction::EmitCXXConstructExpr(clang::CXXConstructExpr const*, clang::CodeGen::AggValueSlot) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGExprCXX.cpp:657:1
#15 0x0000000003a1609e (anonymous namespace)::AggExprEmitter::VisitCXXConstructExpr(clang::CXXConstructExpr const*) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:1319:1
#16 0x0000000003a111d1 (anonymous namespace)::AggExprEmitter::Visit(clang::Expr*) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:108:3
#17 0x0000000003a111d1 clang::CodeGen::CodeGenFunction::EmitAggExpr(clang::Expr const*, clang::CodeGen::AggValueSlot) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:2002:49
#18 0x00000000039d4fee EmitBaseInitializer(clang::CodeGen::CodeGenFunction&, clang::CXXRecordDecl const*, clang::CXXCtorInitializer*) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGClass.cpp:591:11
#19 0x00000000039d450e clang::CodeGen::CodeGenFunction::EmitCtorPrologue(clang::CXXConstructorDecl const*, clang::CXXCtorType, clang::CodeGen::FunctionArgList&) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGClass.cpp:1320:48
#20 0x00000000039d3d16 clang::CodeGen::CodeGenFunction::EmitConstructorBody(clang::CodeGen::FunctionArgList&) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGClass.cpp:877:7
#21 0x000000000394c27e clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl, llvm::Function*, clang::CodeGen::CGFunctionInfo const&) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:0:5
#22 0x0000000003b480c6 clang::CodeGen::CodeGenModule::codegenCXXStructor(clang::GlobalDecl) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGCXX.cpp:215:3
#23 0x00000000038dd513 (anonymous namespace)::ItaniumCXXABI::emitCXXStructor(clang::GlobalDecl) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/ItaniumCXXABI.cpp:4337:28
#24 0x000000000388a5a0 clang::CXXMethodDecl::isVirtual() const /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/include/clang/AST/DeclCXX.h:1995:59
#25 0x000000000388a5a0 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl, llvm::GlobalValue*) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3315:19
#26 0x0000000003880a8f __gnu_cxx::__normal_iterator<clang::CXXRecordDecl const* const*, std::vector<clang::CXXRecordDecl const*, std::allocator<clang::CXXRecordDecl const*> > >::__normal_iterator(clang::CXXRecordDecl const* const* const&) /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_iterator.h:784:20
#27 0x0000000003880a8f std::vector<clang::CXXRecordDecl const*, std::allocator<clang::CXXRecordDecl const*> >::begin() const /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_vector.h:708:16
#28 0x0000000003880a8f std::vector<clang::CXXRecordDecl const*, std::allocator<clang::CXXRecordDecl const*> >::empty() const /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_vector.h:895:16
#29 0x0000000003880a8f clang::CodeGen::CodeGenModule::EmitDeferred() /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2540:26
#30 0x0000000003880abf __gnu_cxx::__normal_iterator<clang::CXXRecordDecl const* const*, std::vector<clang::CXXRecordDecl const*, std::allocator<clang::CXXRecordDecl const*> > >::__normal_iterator(clang::CXXRecordDecl const* const* const&) /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_iterator.h:784:20
#31 0x0000000003880abf std::vector<clang::CXXRecordDecl const*, std::allocator<clang::CXXRecordDecl const*> >::begin() const /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_vector.h:708:16
#32 0x0000000003880abf std::vector<clang::CXXRecordDecl const*, std::allocator<clang::CXXRecordDecl const*> >::empty() const /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_vector.h:895:16
#33 0x0000000003880abf clang::CodeGen::CodeGenModule::EmitDeferred() /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2542:7
#34 0x000000000387ee39 clang::CodeGen::CodeGenModule::Release() /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:506:3
#35 0x000000000400e224 (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit(clang::ASTContext&) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:275:11
#36 0x000000000400c4c9 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:306:13
#37 0x0000000005029ba4 __gnu_cxx::__normal_iterator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >*, std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> > > > >::__normal_iterator(std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >* const&) /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_iterator.h:784:20
#38 0x0000000005029ba4 std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> > > >::begin() /usr/lib/gcc/x86_64-redhat-linux/8/../../../../include/c++/8/bits/stl_vector.h:699:16
#39 0x0000000005029ba4 void clang::finalize<std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> > > > >(std::vector<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> >, std::allocator<std::unique_ptr<clang::TemplateInstantiationCallback, std::default_delete<clang::TemplateInstantiationCallback> > > >&, clang::Sema const&) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/include/clang/Sema/TemplateInstCallback.h:54:16
#40 0x0000000005029ba4 clang::ParseAST(clang::Sema&, bool, bool) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/Parse/ParseAST.cpp:178:3
#41 0x0000000003f44321 clang::FrontendAction::Execute() /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/Frontend/FrontendAction.cpp:971:10
#42 0x0000000003ec9acf llvm::Error::getPtr() const /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/llvm/include/llvm/Support/Error.h:271:42
#43 0x0000000003ec9acf llvm::Error::operator bool() /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/llvm/include/llvm/Support/Error.h:234:16
#44 0x0000000003ec9acf clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1036:23
#45 0x0000000004005ae9 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:263:25
#46 0x00000000022d8086 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/tools/driver/cc1_main.cpp:248:15
#47 0x00000000022d60dd ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&) /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/tools/driver/driver.cpp:317:12
#48 0x00000000022d5e83 main /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/tools/driver/driver.cpp:388:12
#49 0x00007ffff68b9493 __libc_start_main (/lib64/libc.so.6+0x23493)
#50 0x00000000022d31ae _start (/export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/stage2/bin/clang-14+0x22d31ae)
clang-14: error: unable to execute command: Aborted (core dumped)
clang-14: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 14.0.0 (ssh://git@stash.orcsoftware.com/int/rpmbuild.git 527496b29c25d554a137f9923c4f1167781952f4)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/stage2/bin
clang-14: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang-14: note: diagnostic msg: /tmp/file-a87f58.cpp
clang-14: note: diagnostic msg: /tmp/file-a87f58.sh
clang-14: note: diagnostic msg:

********************

note gdb shows slightly different stack

(gdb) bt
#0  0x00007ffff68cd37f in raise () from /lib64/libc.so.6
#1  0x00007ffff68b7e7e in abort () from /lib64/libc.so.6
#2  0x00007ffff68b7c89 in __assert_fail_base.cold.0 () from /lib64/libc.so.6
#3  0x00007ffff68c5a76 in __assert_fail () from /lib64/libc.so.6
#4  0x00000000039019a6 in clang::CodeGen::CodeGenFunction::EmitCall (this=0x7fffffff72f8, CallInfo=..., Callee=..., ReturnValue=..., CallArgs=..., callOrInvoke=0x0, IsMustTail=<optimized out>, Loc=...)
    at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGCall.cpp:4655
#5  0x00000000039d88a4 in clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall (this=this@entry=0x7fffffff72f8, D=D@entry=0x672dc60, Type=Type@entry=clang::Ctor_Base, ForVirtualBase=<optimized out>, Delegating=148, This=..., Args=...,
    Overlap=clang::CodeGen::AggValueSlot::DoesNotOverlap, Loc=..., NewPointerIsChecked=<optimized out>) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGClass.cpp:2181
#6  0x00000000039d7fee in clang::CodeGen::CodeGenFunction::EmitCXXConstructorCall (this=0x7fffffff72f8, D=0x7fffffff5b70, Type=clang::Ctor_Complete, ForVirtualBase=48, Delegating=52, ThisAVS=..., E=0x672dfb0)
    at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGClass.cpp:2095
#7  0x0000000003b60b4e in clang::CodeGen::CodeGenFunction::EmitCXXConstructExpr (this=0x7fffffff72f8, E=0x672dfb0, Dest=...) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGExprCXX.cpp:655
#8  0x0000000003a1609e in (anonymous namespace)::AggExprEmitter::VisitCXXConstructExpr (this=0x7fffffff6e98, E=0x672dfb0) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:1318
#9  0x0000000003a111d1 in (anonymous namespace)::AggExprEmitter::Visit (this=0x7fffffff6e98, E=0x672dfb0) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:107
#10 clang::CodeGen::CodeGenFunction::EmitAggExpr (this=0x7fffffff72f8, E=0x672dfb0, Slot=...) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGExprAgg.cpp:2002
#11 0x00000000039d4fee in EmitBaseInitializer (CGF=..., ClassDecl=ClassDecl@entry=0x6728ab0, BaseInit=0x672dff0) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGClass.cpp:589
#12 0x00000000039d450e in clang::CodeGen::CodeGenFunction::EmitCtorPrologue (this=this@entry=0x7fffffff72f8, CD=CD@entry=0x672a0f0, CtorType=CtorType@entry=clang::Ctor_Complete, Args=...) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGClass.cpp:1327
#13 0x00000000039d3d16 in clang::CodeGen::CodeGenFunction::EmitConstructorBody (this=0x7fffffff72f8, Args=...) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGClass.cpp:874
#14 0x000000000394c27e in clang::CodeGen::CodeGenFunction::GenerateCode (this=0x7fffffff72f8, GD=..., Fn=<optimized out>, FnInfo=...) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenFunction.cpp:1409
#15 0x0000000003b480c6 in clang::CodeGen::CodeGenModule::codegenCXXStructor (this=0x66abcb0, GD=...) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CGCXX.cpp:215
#16 0x00000000038dd513 in (anonymous namespace)::ItaniumCXXABI::emitCXXStructor (this=0x667cf80, GD=...) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/ItaniumCXXABI.cpp:4337
#17 0x000000000388a5a0 in clang::CodeGen::CodeGenModule::EmitGlobalDefinition (this=this@entry=0x66abcb0, GD=..., GV=GV@entry=0x673f0f8) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:3309
#18 0x0000000003880a8f in clang::CodeGen::CodeGenModule::EmitDeferred (this=this@entry=0x66abcb0) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2535
#19 0x0000000003880abf in clang::CodeGen::CodeGenModule::EmitDeferred (this=0x66abcb0) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:2541
#20 0x000000000387ee39 in clang::CodeGen::CodeGenModule::Release (this=0x2) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp:505
#21 0x000000000400e224 in (anonymous namespace)::CodeGeneratorImpl::HandleTranslationUnit (this=0x66a9da0, Ctx=...) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/ModuleBuilder.cpp:271
#22 0x000000000400c4c9 in clang::BackendConsumer::HandleTranslationUnit (this=0x66a9b80, C=...) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/CodeGen/CodeGenAction.cpp:304
#23 0x0000000005029ba4 in clang::ParseAST (S=..., PrintStats=false, SkipFunctionBodies=<optimized out>) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/Parse/ParseAST.cpp:171
#24 0x0000000003f44321 in clang::FrontendAction::Execute (this=0x667eb20) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/Frontend/FrontendAction.cpp:967
#25 0x0000000003ec9acf in clang::CompilerInstance::ExecuteAction (this=0x6679fb0, Act=...) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/Frontend/CompilerInstance.cpp:1036
#26 0x0000000004005ae9 in clang::ExecuteCompilerInvocation (Clang=Clang@entry=0x6679fb0) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:263
#27 0x00000000022d8086 in cc1_main (Argv=..., Argv0=0x7fffffffd94a "/export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/stage2/bin/clang-14", MainAddr=0x22d32c0 <GetExecutablePath[abi:cxx11](char const*, bool)>)
    at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/tools/driver/cc1_main.cpp:248
#28 0x00000000022d60dd in ExecuteCC1Tool (ArgV=...) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/tools/driver/driver.cpp:317
#29 0x00000000022d5e83 in main (Argc=<optimized out>, Argv=<optimized out>) at /export/home/dkurkin/rpmbuild/BUILD/llvm14-14.0.0/llvm-project/clang/tools/driver/driver.cpp:388

code to reproduce the problem

namespace {
template <typename _Tp> _Tp forward();
}
namespace std {
template <typename _Tp> struct _MakeUniq { typedef _Tp __single_object; };
template <typename _Tp, typename... _Args>
typename _MakeUniq<_Tp>::__single_object make_unique(_Args &&...) {
  _Tp(forward<_Args>()...);
}
} // namespace std

class S;

class M {
  int r();
  S & m_s;
};

class C;
class A {
public:
  C & c();
};

class SD;

class S {
public:
  template <typename T = A> T a();
  SD * sd();
};

class I {
public:
  I(S, C &, A);
};

class SDH {
public:
  SDH(S, C &, A, SD *);
};

class SO : public virtual I {
  using super = I;
  using super::super;
};

class SF
    : SDH
    , SO
{
public:
  SF(S s, C &c, A a, SD *sd)
      : I(s, c, a),                              // without this line clang doesn't crash
        SDH(s, c, a, sd),
        SO(s, c, a) {}
};

int M::r() {
  std::make_unique<SF>(
      m_s, m_s.a().c(), m_s.a(),
      m_s.sd());
}
llvmbot commented 2 years ago

@llvm/issue-subscribers-clang-codegen

DimitryAndric commented 2 years ago

I believe this was fixed by 45084eab5e6, @aeubanks can you please confirm? I think this fix should be merged to release/14.x

DimitryAndric commented 2 years ago

Ah no, it still asserts in the same way with quite recent 5c9f3ec4ad5 (llvmorg-15-init-11439-g5c9f3ec4ad5) and -no-opaque-pointers (which got enabled in 702d5de4380b1e1554e5b90863093c3a57f76f70 by @nikic):

$ ~/ins/llvmorg-15-init-11439-g5c9f3ec4ad5/bin/clang -cc1 -S -no-opaque-pointers pr54950.cpp
Assertion failed: (PtrTy->isOpaqueOrPointeeTypeMatches(IRFuncTy)), function EmitCall, file /home/dim/src/llvm/llvm-project/clang/lib/CodeGen/CGCall.cpp, line 4736.
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: /home/dim/ins/llvmorg-15-init-11439-g5c9f3ec4ad5/bin/clang -cc1 -S -no-opaque-pointers pr54950.cpp
1.      <eof> parser at end of file
2.      Per-file LLVM IR generation
3.      pr54950.cpp:53:3: Generating code for declaration 'SF::SF'
#0 0x0000000003ce43b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/dim/ins/llvmorg-15-init-11439-g5c9f3ec4ad5/bin/clang+0x3ce43b8)
#1 0x0000000003ce21b8 llvm::sys::RunSignalHandlers() (/home/dim/ins/llvmorg-15-init-11439-g5c9f3ec4ad5/bin/clang+0x3ce21b8)
#2 0x0000000003ce4b50 SignalHandler(int) Signals.cpp:0:0
#3 0x000000082849ee00 handle_signal /usr/src/lib/libthr/thread/thr_sig.c:0:3
DimitryAndric commented 2 years ago

Further minimized:

// clang -cc1 -S -no-opaque-pointers pr54950-min.cpp
struct I {
  I(int, int, int);
};
struct SDH {
  SDH(int, int, int, int);
};
struct SO : virtual I {
  using super = I;
  using super::super;
};
struct SF : SDH, SO {
  SF() : I(1, 1, 1), SDH(1, 1, 1, 1), SO(1, 1, 1) {}
};
void r() { SF(); }
fhahn commented 2 years ago

Also reproduces on current main: https://clang.godbolt.org/z/xvsxjn576