diff options
author | David Blaikie <dblaikie@gmail.com> | 2018-08-16 21:29:55 +0000 |
---|---|---|
committer | David Blaikie <dblaikie@gmail.com> | 2018-08-16 21:29:55 +0000 |
commit | 66cf14d06b1c5d20417e312fabd14ffaf4314ae3 (patch) | |
tree | 9c3245caddc10c62c973c81438897198a1477530 /llvm/lib | |
parent | ed89d069f4d6be2913ef5a1ae8fd2f9b28ddaab2 (diff) | |
download | bcm5719-llvm-66cf14d06b1c5d20417e312fabd14ffaf4314ae3.tar.gz bcm5719-llvm-66cf14d06b1c5d20417e312fabd14ffaf4314ae3.zip |
DebugInfo: Add metadata support for disabling DWARF pub sections
In cases where the debugger load time is a worthwhile tradeoff (or less
costly - such as loading from a DWP instead of a variety of DWOs
(possibly over a high-latency/distributed filesystem)) against object
file size, it can be reasonable to disable pubnames and corresponding
gdb-index creation in the linker.
A backend-flag version of this was implemented for NVPTX in
D44385/r327994 - which was fine for NVPTX which wouldn't mix-and-match
CUs. Now that it's going to be a user-facing option (likely powered by
"-gno-pubnames", the same as GCC) it should be encoded in the
DICompileUnit so it can vary per-CU.
After this, likely the NVPTX support should be migrated to the metadata
& the previous flag implementation should be removed.
Reviewers: aprantl
Differential Revision: https://reviews.llvm.org/D50213
llvm-svn: 339939
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/AsmParser/LLLexer.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 30 | ||||
-rw-r--r-- | llvm/lib/AsmParser/LLToken.h | 1 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Reader/MetadataLoader.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 24 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 49 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h | 17 | ||||
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 11 | ||||
-rw-r--r-- | llvm/lib/IR/DIBuilder.cpp | 5 | ||||
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/IR/DebugInfoMetadata.cpp | 25 |
14 files changed, 141 insertions, 48 deletions
diff --git a/llvm/lib/AsmParser/LLLexer.cpp b/llvm/lib/AsmParser/LLLexer.cpp index 437579a12a8..d868ec286aa 100644 --- a/llvm/lib/AsmParser/LLLexer.cpp +++ b/llvm/lib/AsmParser/LLLexer.cpp @@ -910,6 +910,11 @@ lltok::Kind LLLexer::LexIdentifier() { return lltok::EmissionKind; } + if (Keyword == "GNU" || Keyword == "None" || Keyword == "Default") { + StrVal.assign(Keyword.begin(), Keyword.end()); + return lltok::NameTableKind; + } + // Check for [us]0x[0-9A-Fa-f]+ which are Hexadecimal constant generated by // the CFE to avoid forcing it to deal with 64-bit numbers. if ((TokStart[0] == 'u' || TokStart[0] == 's') && diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 92cb53068dd..c156a60ffa7 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3718,6 +3718,13 @@ struct EmissionKindField : public MDUnsignedField { EmissionKindField() : MDUnsignedField(0, DICompileUnit::LastEmissionKind) {} }; +struct NameTableKindField : public MDUnsignedField { + NameTableKindField() + : MDUnsignedField( + 0, (unsigned) + DICompileUnit::DebugNameTableKind::LastDebugNameTableKind) {} +}; + struct DIFlagField : public MDFieldImpl<DINode::DIFlags> { DIFlagField() : MDFieldImpl(DINode::FlagZero) {} }; @@ -3938,6 +3945,25 @@ bool LLParser::ParseMDField(LocTy Loc, StringRef Name, EmissionKindField &Result template <> bool LLParser::ParseMDField(LocTy Loc, StringRef Name, + NameTableKindField &Result) { + if (Lex.getKind() == lltok::APSInt) + return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result)); + + if (Lex.getKind() != lltok::NameTableKind) + return TokError("expected nameTable kind"); + + auto Kind = DICompileUnit::getNameTableKind(Lex.getStrVal()); + if (!Kind) + return TokError("invalid nameTable kind" + Twine(" '") + Lex.getStrVal() + + "'"); + assert(((unsigned)*Kind) <= Result.Max && "Expected valid nameTable kind"); + Result.assign((unsigned)*Kind); + Lex.Lex(); + return false; +} + +template <> +bool LLParser::ParseMDField(LocTy Loc, StringRef Name, DwarfAttEncodingField &Result) { if (Lex.getKind() == lltok::APSInt) return ParseMDField(Loc, Name, static_cast<MDUnsignedField &>(Result)); @@ -4448,7 +4474,7 @@ bool LLParser::ParseDICompileUnit(MDNode *&Result, bool IsDistinct) { OPTIONAL(dwoId, MDUnsignedField, ); \ OPTIONAL(splitDebugInlining, MDBoolField, = true); \ OPTIONAL(debugInfoForProfiling, MDBoolField, = false); \ - OPTIONAL(gnuPubnames, MDBoolField, = false); + OPTIONAL(nameTableKind, NameTableKindField, ); PARSE_MD_FIELDS(); #undef VISIT_MD_FIELDS @@ -4456,7 +4482,7 @@ bool LLParser::ParseDICompileUnit(MDNode *&Result, bool IsDistinct) { Context, language.Val, file.Val, producer.Val, isOptimized.Val, flags.Val, runtimeVersion.Val, splitDebugFilename.Val, emissionKind.Val, enums.Val, retainedTypes.Val, globals.Val, imports.Val, macros.Val, dwoId.Val, - splitDebugInlining.Val, debugInfoForProfiling.Val, gnuPubnames.Val); + splitDebugInlining.Val, debugInfoForProfiling.Val, nameTableKind.Val); return false; } diff --git a/llvm/lib/AsmParser/LLToken.h b/llvm/lib/AsmParser/LLToken.h index 8d8c7e99656..2da14da4a43 100644 --- a/llvm/lib/AsmParser/LLToken.h +++ b/llvm/lib/AsmParser/LLToken.h @@ -434,6 +434,7 @@ enum Kind { DwarfLang, // DW_LANG_foo DwarfCC, // DW_CC_foo EmissionKind, // lineTablesOnly + NameTableKind, // GNU DwarfOp, // DW_OP_foo DIFlag, // DIFlagFoo DwarfMacinfo, // DW_MACINFO_foo diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp index 5c8385039e1..a48bbcc2f2d 100644 --- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp +++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp @@ -1393,7 +1393,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata( Record.size() <= 14 ? 0 : Record[14], Record.size() <= 16 ? true : Record[16], Record.size() <= 17 ? false : Record[17], - Record.size() <= 18 ? false : Record[18]); + Record.size() <= 18 ? 0 : Record[18]); MetadataList.assignValue(CU, NextMetadataNo); NextMetadataNo++; diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 738253ade4b..8282703d95d 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -1603,7 +1603,7 @@ void ModuleBitcodeWriter::writeDICompileUnit(const DICompileUnit *N, Record.push_back(VE.getMetadataOrNullID(N->getMacros().get())); Record.push_back(N->getSplitDebugInlining()); Record.push_back(N->getDebugInfoForProfiling()); - Record.push_back(N->getGnuPubnames()); + Record.push_back((unsigned)N->getNameTableKind()); Stream.EmitRecord(bitc::METADATA_COMPILE_UNIT, Record, Abbrev); Record.clear(); diff --git a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp index 20b0b8d3fea..119f65e33f5 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp @@ -23,6 +23,7 @@ #include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCSymbol.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetLoweringObjectFile.h" #include <algorithm> #include <cstddef> #include <cstdint> @@ -554,12 +555,21 @@ void llvm::emitDWARF5AccelTable( const DwarfDebug &DD, ArrayRef<std::unique_ptr<DwarfCompileUnit>> CUs) { std::vector<MCSymbol *> CompUnits; for (const auto &CU : enumerate(CUs)) { + if (CU.value()->getCUNode()->getNameTableKind() == + DICompileUnit::DebugNameTableKind::None) + continue; assert(CU.index() == CU.value()->getUniqueID()); const DwarfCompileUnit *MainCU = DD.useSplitDwarf() ? CU.value()->getSkeleton() : CU.value().get(); CompUnits.push_back(MainCU->getLabelBegin()); } + if (CompUnits.empty()) + return; + + Asm->OutStreamer->SwitchSection( + Asm->getObjFileLowering().getDwarfDebugNamesSection()); + Contents.finalize(Asm, "names"); Dwarf5AccelTableWriter<DWARF5AccelTableData>( Asm, Contents, CompUnits, diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 322555a2e7d..a74a9f9fccd 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -249,13 +249,13 @@ DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE( addLinkageName(*VariableDIE, GV->getLinkageName()); if (addToAccelTable) { - DD->addAccelName(GV->getName(), *VariableDIE); + DD->addAccelName(*CUNode, GV->getName(), *VariableDIE); // If the linkage name is different than the name, go ahead and output // that as well into the name table. if (GV->getLinkageName() != "" && GV->getName() != GV->getLinkageName() && DD->useAllLinkageNames()) - DD->addAccelName(GV->getLinkageName(), *VariableDIE); + DD->addAccelName(*CUNode, GV->getLinkageName(), *VariableDIE); } return VariableDIE; @@ -348,7 +348,7 @@ DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) { // Add name to the name table, we do this here because we're guaranteed // to have concrete versions of our DW_TAG_subprogram nodes. - DD->addSubprogramNames(SP, *SPDie); + DD->addSubprogramNames(*CUNode, SP, *SPDie); return *SPDie; } @@ -486,7 +486,7 @@ DIE *DwarfCompileUnit::constructInlinedScopeDIE(LexicalScope *Scope) { // Add name to the name table, we do this here because we're guaranteed // to have concrete versions of our DW_TAG_inlined_subprogram nodes. - DD->addSubprogramNames(InlinedSP, *ScopeDIE); + DD->addSubprogramNames(*CUNode, InlinedSP, *ScopeDIE); return ScopeDIE; } @@ -883,13 +883,17 @@ void DwarfCompileUnit::emitHeader(bool UseOffsets) { } bool DwarfCompileUnit::hasDwarfPubSections() const { - // Opting in to GNU Pubnames/types overrides the default to ensure these are - // generated for things like Gold's gdb_index generation. - if (CUNode->getGnuPubnames()) + switch (CUNode->getNameTableKind()) { + case DICompileUnit::DebugNameTableKind::None: + return false; + // Opting in to GNU Pubnames/types overrides the default to ensure these are + // generated for things like Gold's gdb_index generation. + case DICompileUnit::DebugNameTableKind::GNU: return true; - - return DD->tuneForGDB() && DD->usePubSections() && - !includeMinimalInlineScopes() && !CUNode->isDebugDirectivesOnly(); + case DICompileUnit::DebugNameTableKind::Default: + return DD->tuneForGDB() && DD->usePubSections() && + !includeMinimalInlineScopes() && !CUNode->isDebugDirectivesOnly(); + } } /// addGlobalName - Add a new global name to the compile unit. diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 6ee1de0dba3..435190669a4 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -421,30 +421,35 @@ static StringRef getObjCMethodName(StringRef In) { } // Add the various names to the Dwarf accelerator table names. -void DwarfDebug::addSubprogramNames(const DISubprogram *SP, DIE &Die) { +void DwarfDebug::addSubprogramNames(const DICompileUnit &CU, + const DISubprogram *SP, DIE &Die) { + if (getAccelTableKind() != AccelTableKind::Apple && + CU.getNameTableKind() == DICompileUnit::DebugNameTableKind::None) + return; + if (!SP->isDefinition()) return; if (SP->getName() != "") - addAccelName(SP->getName(), Die); + addAccelName(CU, SP->getName(), Die); // If the linkage name is different than the name, go ahead and output that as // well into the name table. Only do that if we are going to actually emit // that name. if (SP->getLinkageName() != "" && SP->getName() != SP->getLinkageName() && (useAllLinkageNames() || InfoHolder.getAbstractSPDies().lookup(SP))) - addAccelName(SP->getLinkageName(), Die); + addAccelName(CU, SP->getLinkageName(), Die); // If this is an Objective-C selector name add it to the ObjC accelerator // too. if (isObjCClass(SP->getName())) { StringRef Class, Category; getObjCClassCategory(SP->getName(), Class, Category); - addAccelObjC(Class, Die); + addAccelObjC(CU, Class, Die); if (Category != "") - addAccelObjC(Category, Die); + addAccelObjC(CU, Category, Die); // Also add the base method name to the name table. - addAccelName(getObjCMethodName(SP->getName()), Die); + addAccelName(CU, getObjCMethodName(SP->getName()), Die); } } @@ -1537,8 +1542,6 @@ void DwarfDebug::emitAccelDebugNames() { if (getUnits().empty()) return; - Asm->OutStreamer->SwitchSection( - Asm->getObjFileLowering().getDwarfDebugNamesSection()); emitDWARF5AccelTable(Asm, AccelDebugNames, *this, getUnits()); } @@ -1643,7 +1646,8 @@ void DwarfDebug::emitDebugPubSections() { if (!TheU->hasDwarfPubSections()) continue; - bool GnuStyle = TheU->getCUNode()->getGnuPubnames(); + bool GnuStyle = TheU->getCUNode()->getNameTableKind() == + DICompileUnit::DebugNameTableKind::GNU; Asm->OutStreamer->SwitchSection( GnuStyle ? Asm->getObjFileLowering().getDwarfGnuPubNamesSection() @@ -2431,11 +2435,16 @@ void DwarfDebug::addDwarfTypeUnitType(DwarfCompileUnit &CU, // AccelTableKind::Apple, we use the table we got as an argument). If // accelerator tables are disabled, this function does nothing. template <typename DataT> -void DwarfDebug::addAccelNameImpl(AccelTable<DataT> &AppleAccel, StringRef Name, +void DwarfDebug::addAccelNameImpl(const DICompileUnit &CU, + AccelTable<DataT> &AppleAccel, StringRef Name, const DIE &Die) { if (getAccelTableKind() == AccelTableKind::None) return; + if (getAccelTableKind() != AccelTableKind::Apple && + CU.getNameTableKind() == DICompileUnit::DebugNameTableKind::None) + return; + DwarfFile &Holder = useSplitDwarf() ? SkeletonHolder : InfoHolder; DwarfStringPoolEntryRef Ref = Holder.getStringPool().getEntry(*Asm, Name); @@ -2453,22 +2462,26 @@ void DwarfDebug::addAccelNameImpl(AccelTable<DataT> &AppleAccel, StringRef Name, } } -void DwarfDebug::addAccelName(StringRef Name, const DIE &Die) { - addAccelNameImpl(AccelNames, Name, Die); +void DwarfDebug::addAccelName(const DICompileUnit &CU, StringRef Name, + const DIE &Die) { + addAccelNameImpl(CU, AccelNames, Name, Die); } -void DwarfDebug::addAccelObjC(StringRef Name, const DIE &Die) { +void DwarfDebug::addAccelObjC(const DICompileUnit &CU, StringRef Name, + const DIE &Die) { // ObjC names go only into the Apple accelerator tables. if (getAccelTableKind() == AccelTableKind::Apple) - addAccelNameImpl(AccelObjC, Name, Die); + addAccelNameImpl(CU, AccelObjC, Name, Die); } -void DwarfDebug::addAccelNamespace(StringRef Name, const DIE &Die) { - addAccelNameImpl(AccelNamespace, Name, Die); +void DwarfDebug::addAccelNamespace(const DICompileUnit &CU, StringRef Name, + const DIE &Die) { + addAccelNameImpl(CU, AccelNamespace, Name, Die); } -void DwarfDebug::addAccelType(StringRef Name, const DIE &Die, char Flags) { - addAccelNameImpl(AccelTypes, Name, Die); +void DwarfDebug::addAccelType(const DICompileUnit &CU, StringRef Name, + const DIE &Die, char Flags) { + addAccelNameImpl(CU, AccelTypes, Name, Die); } uint16_t DwarfDebug::getDwarfVersion() const { diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h index abf2e43b131..750bbc644d1 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.h @@ -346,8 +346,8 @@ class DwarfDebug : public DebugHandlerBase { void constructAbstractSubprogramScopeDIE(DwarfCompileUnit &SrcCU, LexicalScope *Scope); template <typename DataT> - void addAccelNameImpl(AccelTable<DataT> &AppleAccel, StringRef Name, - const DIE &Die); + void addAccelNameImpl(const DICompileUnit &CU, AccelTable<DataT> &AppleAccel, + StringRef Name, const DIE &Die); void finishVariableDefinitions(); @@ -608,17 +608,20 @@ public: return Ref.resolve(); } - void addSubprogramNames(const DISubprogram *SP, DIE &Die); + void addSubprogramNames(const DICompileUnit &CU, const DISubprogram *SP, + DIE &Die); AddressPool &getAddressPool() { return AddrPool; } - void addAccelName(StringRef Name, const DIE &Die); + void addAccelName(const DICompileUnit &CU, StringRef Name, const DIE &Die); - void addAccelObjC(StringRef Name, const DIE &Die); + void addAccelObjC(const DICompileUnit &CU, StringRef Name, const DIE &Die); - void addAccelNamespace(StringRef Name, const DIE &Die); + void addAccelNamespace(const DICompileUnit &CU, StringRef Name, + const DIE &Die); - void addAccelType(StringRef Name, const DIE &Die, char Flags); + void addAccelType(const DICompileUnit &CU, StringRef Name, const DIE &Die, + char Flags); const MachineFunction *getCurrentFunction() const { return CurFn; } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp index 011f6548a8b..7335a0bb17e 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -795,7 +795,7 @@ void DwarfUnit::updateAcceleratorTables(const DIScope *Context, IsImplementation = CT->getRuntimeLang() == 0 || CT->isObjcClassComplete(); } unsigned Flags = IsImplementation ? dwarf::DW_FLAG_type_implementation : 0; - DD->addAccelType(Ty->getName(), TyDIE, Flags); + DD->addAccelType(*CUNode, Ty->getName(), TyDIE, Flags); if (!Context || isa<DICompileUnit>(Context) || isa<DIFile>(Context) || isa<DINamespace>(Context)) @@ -1168,7 +1168,7 @@ DIE *DwarfUnit::getOrCreateNameSpace(const DINamespace *NS) { addString(NDie, dwarf::DW_AT_name, NS->getName()); else Name = "(anonymous namespace)"; - DD->addAccelNamespace(Name, NDie); + DD->addAccelNamespace(*CUNode, Name, NDie); addGlobalName(Name, NDie, NS->getScope()); if (NS->getExportSymbols()) addFlag(NDie, dwarf::DW_AT_export_symbols); @@ -1417,7 +1417,7 @@ DIE *DwarfUnit::getIndexTyDie() { addUInt(*IndexTyDie, dwarf::DW_AT_byte_size, None, sizeof(int64_t)); addUInt(*IndexTyDie, dwarf::DW_AT_encoding, dwarf::DW_FORM_data1, dwarf::DW_ATE_unsigned); - DD->addAccelType(Name, *IndexTyDie, /*Flags*/ 0); + DD->addAccelType(*CUNode, Name, *IndexTyDie, /*Flags*/ 0); return IndexTyDie; } diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 699b79c8725..fc5eca19c84 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -1604,6 +1604,8 @@ struct MDFieldPrinter { void printDwarfEnum(StringRef Name, IntTy Value, Stringifier toString, bool ShouldSkipZero = true); void printEmissionKind(StringRef Name, DICompileUnit::DebugEmissionKind EK); + void printNameTableKind(StringRef Name, + DICompileUnit::DebugNameTableKind NTK); }; } // end anonymous namespace @@ -1701,6 +1703,13 @@ void MDFieldPrinter::printEmissionKind(StringRef Name, Out << FS << Name << ": " << DICompileUnit::emissionKindString(EK); } +void MDFieldPrinter::printNameTableKind(StringRef Name, + DICompileUnit::DebugNameTableKind NTK) { + if (NTK == DICompileUnit::DebugNameTableKind::Default) + return; + Out << FS << Name << ": " << DICompileUnit::nameTableKindString(NTK); +} + template <class IntTy, class Stringifier> void MDFieldPrinter::printDwarfEnum(StringRef Name, IntTy Value, Stringifier toString, bool ShouldSkipZero) { @@ -1891,7 +1900,7 @@ static void writeDICompileUnit(raw_ostream &Out, const DICompileUnit *N, Printer.printBool("splitDebugInlining", N->getSplitDebugInlining(), true); Printer.printBool("debugInfoForProfiling", N->getDebugInfoForProfiling(), false); - Printer.printBool("gnuPubnames", N->getGnuPubnames(), false); + Printer.printNameTableKind("nameTableKind", N->getNameTableKind()); Out << ")"; } diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp index ee3323c2afe..ce7e8538ca3 100644 --- a/llvm/lib/IR/DIBuilder.cpp +++ b/llvm/lib/IR/DIBuilder.cpp @@ -139,7 +139,8 @@ DICompileUnit *DIBuilder::createCompileUnit( unsigned Lang, DIFile *File, StringRef Producer, bool isOptimized, StringRef Flags, unsigned RunTimeVer, StringRef SplitName, DICompileUnit::DebugEmissionKind Kind, uint64_t DWOId, - bool SplitDebugInlining, bool DebugInfoForProfiling, bool GnuPubnames) { + bool SplitDebugInlining, bool DebugInfoForProfiling, + DICompileUnit::DebugNameTableKind NameTableKind) { assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) || (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) && @@ -149,7 +150,7 @@ DICompileUnit *DIBuilder::createCompileUnit( CUNode = DICompileUnit::getDistinct( VMContext, Lang, File, Producer, isOptimized, Flags, RunTimeVer, SplitName, Kind, nullptr, nullptr, nullptr, nullptr, nullptr, DWOId, - SplitDebugInlining, DebugInfoForProfiling, GnuPubnames); + SplitDebugInlining, DebugInfoForProfiling, NameTableKind); // Create a named metadata so that it is easier to find cu in a module. NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu"); diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index 77585ee30cd..659c924b2fc 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -491,7 +491,7 @@ private: CU->getSplitDebugFilename(), DICompileUnit::LineTablesOnly, EnumTypes, RetainedTypes, GlobalVariables, ImportedEntities, CU->getMacros(), CU->getDWOId(), CU->getSplitDebugInlining(), - CU->getDebugInfoForProfiling(), CU->getGnuPubnames()); + CU->getDebugInfoForProfiling(), CU->getNameTableKind()); } DILocation *getReplacementMDLocation(DILocation *MLD) { diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp index ddd226f1d5d..242d92582c2 100644 --- a/llvm/lib/IR/DebugInfoMetadata.cpp +++ b/llvm/lib/IR/DebugInfoMetadata.cpp @@ -450,7 +450,7 @@ DICompileUnit *DICompileUnit::getImpl( unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes, Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros, uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling, - bool GnuPubnames, StorageType Storage, bool ShouldCreate) { + unsigned NameTableKind, StorageType Storage, bool ShouldCreate) { assert(Storage != Uniqued && "Cannot unique DICompileUnit"); assert(isCanonical(Producer) && "Expected canonical MDString"); assert(isCanonical(Flags) && "Expected canonical MDString"); @@ -463,7 +463,7 @@ DICompileUnit *DICompileUnit::getImpl( return storeImpl(new (array_lengthof(Ops)) DICompileUnit( Context, Storage, SourceLanguage, IsOptimized, RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining, - DebugInfoForProfiling, GnuPubnames, Ops), + DebugInfoForProfiling, NameTableKind, Ops), Storage); } @@ -477,6 +477,15 @@ DICompileUnit::getEmissionKind(StringRef Str) { .Default(None); } +Optional<DICompileUnit::DebugNameTableKind> +DICompileUnit::getNameTableKind(StringRef Str) { + return StringSwitch<Optional<DebugNameTableKind>>(Str) + .Case("Default", DebugNameTableKind::Default) + .Case("GNU", DebugNameTableKind::GNU) + .Case("None", DebugNameTableKind::None) + .Default(None); +} + const char *DICompileUnit::emissionKindString(DebugEmissionKind EK) { switch (EK) { case NoDebug: return "NoDebug"; @@ -487,6 +496,18 @@ const char *DICompileUnit::emissionKindString(DebugEmissionKind EK) { return nullptr; } +const char *DICompileUnit::nameTableKindString(DebugNameTableKind NTK) { + switch (NTK) { + case DebugNameTableKind::Default: + return nullptr; + case DebugNameTableKind::GNU: + return "GNU"; + case DebugNameTableKind::None: + return "None"; + } + return nullptr; +} + DISubprogram *DILocalScope::getSubprogram() const { if (auto *Block = dyn_cast<DILexicalBlockBase>(this)) return Block->getScope()->getSubprogram(); |