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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339939 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
David Blaikie
2018-08-16 21:29:55 +00:00
parent 86864df093
commit cf8a4a5d5e
27 changed files with 289 additions and 76 deletions
+23 -2
View File
@@ -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();