summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2016-02-26 07:04:58 +0000
committerDavid Blaikie <dblaikie@gmail.com>2016-02-26 07:04:58 +0000
commit5d6d4dc3061777393f4d2b830186a2f716c689a0 (patch)
treeb659f77bc6ce79840c23740cfb98e1c3bbbb2947
parentce63c2053d5ff8f67b5bdaf4aea6446315830f1f (diff)
downloadbcm5719-llvm-5d6d4dc3061777393f4d2b830186a2f716c689a0.tar.gz
bcm5719-llvm-5d6d4dc3061777393f4d2b830186a2f716c689a0.zip
llvm-dwp: Support empty .dwo files
Though a bit odd, this is handy for a few reasons - for example, in a build system that wants consistent input/output of build steps, but where split-dwarf might be overriden/disabled by the user on a per-file basis. llvm-svn: 261987
-rw-r--r--llvm/test/tools/llvm-dwp/Inputs/empty.dwobin0 -> 208 bytes
-rw-r--r--llvm/test/tools/llvm-dwp/X86/empty.test8
-rw-r--r--llvm/tools/llvm-dwp/llvm-dwp.cpp20
3 files changed, 19 insertions, 9 deletions
diff --git a/llvm/test/tools/llvm-dwp/Inputs/empty.dwo b/llvm/test/tools/llvm-dwp/Inputs/empty.dwo
new file mode 100644
index 00000000000..c48a82cf4d7
--- /dev/null
+++ b/llvm/test/tools/llvm-dwp/Inputs/empty.dwo
Binary files differ
diff --git a/llvm/test/tools/llvm-dwp/X86/empty.test b/llvm/test/tools/llvm-dwp/X86/empty.test
new file mode 100644
index 00000000000..78e4eb9b889
--- /dev/null
+++ b/llvm/test/tools/llvm-dwp/X86/empty.test
@@ -0,0 +1,8 @@
+RUN: llvm-dwp %p/../Inputs/empty.dwo -o %t
+RUN: llvm-dwarfdump %t | FileCheck %s
+
+CHECK-LABEL: .debug_cu_index
+CHECK-NOT: version
+CHECK-LABEL: .debug_tu_index
+CHECK-NOT: version
+CHECK: .debug_
diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp
index ca40638d801..82b7d12fcb1 100644
--- a/llvm/tools/llvm-dwp/llvm-dwp.cpp
+++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp
@@ -219,6 +219,9 @@ static void
writeIndex(MCStreamer &Out, MCSection *Section,
ArrayRef<unsigned> ContributionOffsets,
const MapVector<uint64_t, UnitIndexEntry> &IndexEntries) {
+ if (IndexEntries.empty())
+ return;
+
unsigned Columns = 0;
for (auto &C : ContributionOffsets)
if (C)
@@ -397,8 +400,9 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
}
}
- assert(!AbbrevSection.empty());
- assert(!InfoSection.empty());
+ if (InfoSection.empty())
+ continue;
+
if (!CurCUIndexSection.empty()) {
DWARFUnitIndex CUIndex(DW_SECT_INFO);
DataExtractor CUIndexData(CurCUIndexSection,
@@ -448,13 +452,11 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
return Err;
}
- if (!TypeIndexEntries.empty()) {
- // Lie about there being no info contributions so the TU index only includes
- // the type unit contribution
- ContributionOffsets[0] = 0;
- writeIndex(Out, MCOFI.getDwarfTUIndexSection(), ContributionOffsets,
- TypeIndexEntries);
- }
+ // Lie about there being no info contributions so the TU index only includes
+ // the type unit contribution
+ ContributionOffsets[0] = 0;
+ writeIndex(Out, MCOFI.getDwarfTUIndexSection(), ContributionOffsets,
+ TypeIndexEntries);
// Lie about the type contribution
ContributionOffsets[DW_SECT_TYPES - DW_SECT_INFO] = 0;
OpenPOWER on IntegriCloud