https://llvm.org/bugs/show_bug.cgi?id=26037
Bug ID: 26037 Summary: LTO crashes after the linker ignores (r256003) not-imported DISubprograms that are otherwise used as a DIImportedEntity's entity. Product: libraries Version: trunk Hardware: PC OS: All Status: NEW Severity: normal Priority: P Component: Linker Assignee: unassignedb...@nondot.org Reporter: ahmed.bouga...@gmail.com CC: llvm-bugs@lists.llvm.org Classification: Unclassified Since r256003, OSX bootstraps (e.g., http://lab.llvm.org:8080/green/job/llvm-stage2-cmake-RgLTO/) have been crashing with assertion failures. I think the issue is reducible to: $ cat a.cpp namespace A { void a(); } using A::a; $ cat main.cpp int main() { return 0; } $ clang++ -flto -g3 a.cpp main.cpp clang-3.8: error: unable to execute command: Segmentation fault: 11 clang-3.8: error: linker command failed due to signal (use -v to see invocation) Here, the `using' translates into a DIImportedEntity, which references an otherwise not-imported DISubprogram, "A::a". findNeededSubprograms, introduced by r256003, only looks at explicitly imported subprograms, which causes this one to not be linked in. Here's some more relevant details: The failure is: Assertion failed: (Val && "isa<> used on a null pointer"), function doit, file /Users/buildslave/jenkins/sharedspace/phase1@2/llvm/include/llvm/Support/Casting.h, line 95. In: frame #3: 0x00000001034e0ad1 libLTO.dylib`__assert_rtn + 81 frame #4: 0x0000000103511313 libLTO.dylib`llvm::DwarfCompileUnit::constructImportedEntityDIE(llvm::DIImportedEntity const*) + 1075 frame #5: 0x000000010351678e libLTO.dylib`llvm::DwarfDebug::constructAndAddImportedEntityDIE(llvm::DwarfCompileUnit&, llvm::DIImportedEntity const*) + 94 frame #6: 0x0000000103515105 libLTO.dylib`llvm::DwarfDebug::beginModule() + 1333 frame #7: 0x0000000103514b63 libLTO.dylib`llvm::DwarfDebug::DwarfDebug(llvm::AsmPrinter*, llvm::Module*) + 2275 frame #8: 0x00000001034f0f68 libLTO.dylib`llvm::AsmPrinter::doInitialization(llvm::Module&) + 1496 frame #9: 0x00000001033c513b libLTO.dylib`llvm::FPPassManager::doInitialization(llvm::Module&) + 75 frame #10: 0x00000001033c5560 libLTO.dylib`llvm::legacy::PassManagerImpl::run(llvm::Module&) + 816 frame #11: 0x00000001038db37b libLTO.dylib`codegen(llvm::Module*, llvm::raw_pwrite_stream&, llvm::Target const*, llvm::StringRef, llvm::StringRef, llvm::TargetOptions const&, llvm::Reloc::Model, llvm::CodeModel::Model, llvm::CodeGenOpt::Level, llvm::TargetMachine::CodeGenFileType) + 315 frame #12: 0x00000001038db043 libLTO.dylib`llvm::splitCodeGen(std::__1::unique_ptr<llvm::Module, std::__1::default_delete<llvm::Module> >, llvm::ArrayRef<llvm::raw_pwrite_stream*>, llvm::StringRef, llvm::StringRef, llvm::TargetOptions const&, llvm::Reloc::Model, llvm::CodeModel::Model, llvm::CodeGenOpt::Level, llvm::TargetMachine::CodeGenFileType) + 371 frame #13: 0x000000010342dee2 libLTO.dylib`llvm::LTOCodeGenerator::compileOptimized(llvm::ArrayRef<llvm::raw_pwrite_stream*>) + 274 frame #14: 0x000000010342dbd2 libLTO.dylib`llvm::LTOCodeGenerator::compileOptimizedToFile(char const**) + 354 frame #15: 0x000000010342dfa3 libLTO.dylib`llvm::LTOCodeGenerator::compileOptimized() + 51 frame #16: 0x000000010342e4c2 libLTO.dylib`llvm::LTOCodeGenerator::compile(bool, bool, bool, bool) + 50 frame #17: 0x000000010280a1c0 libLTO.dylib`lto_codegen_compile + 64 caused by: frame #10: 0x000000010ae1838e libLTO.dylib`llvm::DwarfCompileUnit::constructImportedEntityDIE(this=0x00000002c1e033e0, Module=0x000000027e3f2ee8) + 174 at DwarfCompileUnit.cpp:646 643 insertDIE(Module, IMDie); 644 DIE *EntityDie; 645 auto *Entity = resolve(Module->getEntity()); -> 646 if (auto *NS = dyn_cast<DINamespace>(Entity)) 647 EntityDie = getOrCreateNameSpace(NS); 648 else if (auto *M = dyn_cast<DIModule>(Entity)) 649 EntityDie = getOrCreateModule(M); (lldb) p Entity (llvm::DINode *) $0 = 0x0000000000000000 In the relevant .bc (MIRParser.cpp.o), we have: !97361 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !1038, entity: !90731, line: 56) !90731 = distinct !DISubprogram(name: "isspace", linkageName: "_Z7isspacei", scope: !90732, file: !90732, line: 267, type: !90733, isLocal: false, isDefinition: true, scopeLine: 268, flags: DIFlagPrototyped, isOptimized: true, variables: !90735) But the entity just disappeared: (lldb) p ({ for (auto *IE : CUNode->getImportedEntities()) { IE->dump(); } }) <0x10f104628> = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: <0x1006f8568>, entity: <0x1024d3658>, line: 48) <0x10f104668> = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: <0x1006f8568>, entity: <0x10230bef8>, line: 49) [..] <0x10f115968> = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: <0x1006f8568>, entity: <0x10f115920>, line: 55) <0x27e3f2ee8> = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: <0x1006f8568>, line: 56) <0x10f115b88> = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: <0x1006f8568>, entity: <0x10f115b40>, line: 57) [..] whereas: $ llvm-dis lib/CodeGen/MIRParser/CMakeFiles/LLVMMIRParser.dir/MIRParser.cpp.o -o - | grep '!DIImportedEntity' !97055 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !1038, entity: !2714, line: 48) !97056 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !1038, entity: !1454, line: 49) !97057 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !1038, entity: !97058, line: 53) [..] !97359 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !1038, entity: !97360, line: 55) !97361 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !1038, entity: !90731, line: 56) !97362 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !1038, entity: !97363, line: 57) [..] -- You are receiving this mail because: You are on the CC list for the bug.
_______________________________________________ llvm-bugs mailing list llvm-bugs@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs