summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2018-11-13 20:08:10 +0000
committerDavid Blaikie <dblaikie@gmail.com>2018-11-13 20:08:10 +0000
commitbb279116f29617467a176f065c8ca4e84174e7f7 (patch)
tree5faf1969b2e9d4b43ddf8b30d5abd0ee08760897 /llvm/lib
parent2af3416618e6d521eade365eecf5ab353cdf5b6c (diff)
downloadbcm5719-llvm-bb279116f29617467a176f065c8ca4e84174e7f7.tar.gz
bcm5719-llvm-bb279116f29617467a176f065c8ca4e84174e7f7.zip
DebugInfo: Add a CU metadata attribute for use of DWARF ranges base address specifiers
Summary: Ranges base address specifiers can save a lot of object size in relocation records especially in optimized builds. For an optimized self-host build of Clang with split DWARF and debug info compression in object files, but uncompressed debug info in the executable, this change produces about 18% smaller object files and 6% larger executable. While it would've been nice to turn this on by default, gold's 32 bit gdb-index support crashes on this input & I don't think there's any perfect heuristic to implement solely in LLVM that would suffice - so we'll need a flag one way or another (also possible people might want to aggressively optimized for executable size that contains debug info (even with compression this would still come at some cost to executable size)) - so let's plumb it through. Differential Revision: https://reviews.llvm.org/D54242 llvm-svn: 346788
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/AsmParser/LLParser.cpp6
-rw-r--r--llvm/lib/Bitcode/Reader/MetadataLoader.cpp3
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp2
-rw-r--r--llvm/lib/IR/AsmWriter.cpp1
-rw-r--r--llvm/lib/IR/DIBuilder.cpp5
-rw-r--r--llvm/lib/IR/DebugInfo.cpp3
-rw-r--r--llvm/lib/IR/DebugInfoMetadata.cpp6
7 files changed, 17 insertions, 9 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp
index 856be2fb64a..c9ffbc04eb9 100644
--- a/llvm/lib/AsmParser/LLParser.cpp
+++ b/llvm/lib/AsmParser/LLParser.cpp
@@ -4497,7 +4497,8 @@ bool LLParser::ParseDICompileUnit(MDNode *&Result, bool IsDistinct) {
OPTIONAL(dwoId, MDUnsignedField, ); \
OPTIONAL(splitDebugInlining, MDBoolField, = true); \
OPTIONAL(debugInfoForProfiling, MDBoolField, = false); \
- OPTIONAL(nameTableKind, NameTableKindField, );
+ OPTIONAL(nameTableKind, NameTableKindField, ); \
+ OPTIONAL(debugBaseAddress, MDBoolField, = false);
PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS
@@ -4505,7 +4506,8 @@ 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, nameTableKind.Val);
+ splitDebugInlining.Val, debugInfoForProfiling.Val, nameTableKind.Val,
+ debugBaseAddress.Val);
return false;
}
diff --git a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
index e77965be216..7af95cb73e5 100644
--- a/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
+++ b/llvm/lib/Bitcode/Reader/MetadataLoader.cpp
@@ -1395,7 +1395,8 @@ 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 ? 0 : Record[18]);
+ Record.size() <= 18 ? 0 : Record[18],
+ Record.size() <= 19 ? 0 : Record[19]);
MetadataList.assignValue(CU, NextMetadataNo);
NextMetadataNo++;
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 7f555a52fcf..9c0480fa745 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2287,7 +2287,7 @@ static void emitRangeList(DwarfDebug &DD, AsmPrinter *Asm,
// contributions.
auto *Base = CUBase;
if (!Base && (P.second.size() > 1 || DwarfVersion < 5) &&
- (UseDwarfRangesBaseAddressSpecifier || DwarfVersion >= 5)) {
+ (CU.getCUNode()->getRangesBaseAddress() || DwarfVersion >= 5)) {
BaseIsSet = true;
// FIXME/use care: This may not be a useful base address if it's not
// the lowest address/range in this object.
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 3b575739263..8cfbf6da7fb 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1910,6 +1910,7 @@ static void writeDICompileUnit(raw_ostream &Out, const DICompileUnit *N,
Printer.printBool("debugInfoForProfiling", N->getDebugInfoForProfiling(),
false);
Printer.printNameTableKind("nameTableKind", N->getNameTableKind());
+ Printer.printBool("rangesBaseAddress", N->getRangesBaseAddress(), false);
Out << ")";
}
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index df3578ea87f..0254312329a 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -140,7 +140,7 @@ DICompileUnit *DIBuilder::createCompileUnit(
StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
DICompileUnit::DebugEmissionKind Kind, uint64_t DWOId,
bool SplitDebugInlining, bool DebugInfoForProfiling,
- DICompileUnit::DebugNameTableKind NameTableKind) {
+ DICompileUnit::DebugNameTableKind NameTableKind, bool RangesBaseAddress) {
assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
(Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
@@ -150,7 +150,8 @@ DICompileUnit *DIBuilder::createCompileUnit(
CUNode = DICompileUnit::getDistinct(
VMContext, Lang, File, Producer, isOptimized, Flags, RunTimeVer,
SplitName, Kind, nullptr, nullptr, nullptr, nullptr, nullptr, DWOId,
- SplitDebugInlining, DebugInfoForProfiling, NameTableKind);
+ SplitDebugInlining, DebugInfoForProfiling, NameTableKind,
+ RangesBaseAddress);
// 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 02b7953cb5b..8f383875ad2 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -491,7 +491,8 @@ private:
CU->getSplitDebugFilename(), DICompileUnit::LineTablesOnly, EnumTypes,
RetainedTypes, GlobalVariables, ImportedEntities, CU->getMacros(),
CU->getDWOId(), CU->getSplitDebugInlining(),
- CU->getDebugInfoForProfiling(), CU->getNameTableKind());
+ CU->getDebugInfoForProfiling(), CU->getNameTableKind(),
+ CU->getRangesBaseAddress());
}
DILocation *getReplacementMDLocation(DILocation *MLD) {
diff --git a/llvm/lib/IR/DebugInfoMetadata.cpp b/llvm/lib/IR/DebugInfoMetadata.cpp
index bb49cb2109a..2e84f9c5581 100644
--- a/llvm/lib/IR/DebugInfoMetadata.cpp
+++ b/llvm/lib/IR/DebugInfoMetadata.cpp
@@ -470,7 +470,8 @@ DICompileUnit *DICompileUnit::getImpl(
unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros,
uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
- unsigned NameTableKind, StorageType Storage, bool ShouldCreate) {
+ unsigned NameTableKind, bool RangesBaseAddress, StorageType Storage,
+ bool ShouldCreate) {
assert(Storage != Uniqued && "Cannot unique DICompileUnit");
assert(isCanonical(Producer) && "Expected canonical MDString");
assert(isCanonical(Flags) && "Expected canonical MDString");
@@ -483,7 +484,8 @@ DICompileUnit *DICompileUnit::getImpl(
return storeImpl(new (array_lengthof(Ops)) DICompileUnit(
Context, Storage, SourceLanguage, IsOptimized,
RuntimeVersion, EmissionKind, DWOId, SplitDebugInlining,
- DebugInfoForProfiling, NameTableKind, Ops),
+ DebugInfoForProfiling, NameTableKind, RangesBaseAddress,
+ Ops),
Storage);
}
OpenPOWER on IntegriCloud