[llvm-dwp] Include only the non-empty columns in the cu_index

llvm-svn: 254555
This commit is contained in:
David Blaikie 2015-12-02 22:01:56 +00:00
parent 3e3bb95b69
commit b3757c008b
2 changed files with 20 additions and 8 deletions

View File

@ -42,7 +42,11 @@ CHECK: DW_AT_name {{.*}} "b"
CHECK: DW_TAG_formal_parameter CHECK: DW_TAG_formal_parameter
CHECK: .debug_cu_index contents: CHECK: .debug_cu_index contents:
FIXME: Emit and verify the cu_index contents Ensure only the relevant/contained sections are included in the table:
CHECK: Index Signature INFO ABBREV STR_OFFSETS
Don't bother checking the Signatures, they aren't correct yet.
CHECK: [0x00000000, 0x00000029) [0x00000000, 0x00000031) [0x00000000, 0x00000010)
CHECK: [0x00000029, 0x0000005e) [0x00000031, 0x00000075) [0x00000010, 0x00000024)
CHECK: .debug_str.dwo contents: CHECK: .debug_str.dwo contents:
CHECK: "clang version CHECK: "clang version

View File

@ -157,9 +157,14 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
return Err; return Err;
} }
unsigned Columns = 0;
for (auto &C : ContributionOffsets)
if (C)
++Columns;
Out.SwitchSection(MCOFI.getDwarfCUIndexSection()); Out.SwitchSection(MCOFI.getDwarfCUIndexSection());
Out.EmitIntValue(2, 4); // Version Out.EmitIntValue(2, 4); // Version
Out.EmitIntValue(8, 4); // Columns Out.EmitIntValue(Columns, 4); // Columns
Out.EmitIntValue(IndexEntries.size(), 4); // Num Units Out.EmitIntValue(IndexEntries.size(), 4); // Num Units
// FIXME: This is not the right number of buckets for a real hash. // FIXME: This is not the right number of buckets for a real hash.
Out.EmitIntValue(IndexEntries.size(), 4); // Num Buckets Out.EmitIntValue(IndexEntries.size(), 4); // Num Buckets
@ -173,18 +178,21 @@ static std::error_code write(MCStreamer &Out, ArrayRef<std::string> Inputs) {
Out.EmitIntValue(i + 1, 4); Out.EmitIntValue(i + 1, 4);
// Write the column headers (which sections will appear in the table) // Write the column headers (which sections will appear in the table)
for (size_t i = 1; i != 9; ++i) for (size_t i = 0; i != array_lengthof(ContributionOffsets); ++i)
Out.EmitIntValue(i, 4); if (ContributionOffsets[i])
Out.EmitIntValue(i + DW_SECT_INFO, 4);
// Write the offsets. // Write the offsets.
for (const auto &E : IndexEntries) for (const auto &E : IndexEntries)
for (const auto &C : E.Contributions) for (size_t i = 0; i != array_lengthof(E.Contributions); ++i)
Out.EmitIntValue(C.Offset, 4); if (ContributionOffsets[i])
Out.EmitIntValue(E.Contributions[i].Offset, 4);
// Write the lengths. // Write the lengths.
for (const auto &E : IndexEntries) for (const auto &E : IndexEntries)
for (const auto &C : E.Contributions) for (size_t i = 0; i != array_lengthof(E.Contributions); ++i)
Out.EmitIntValue(C.Length, 4); if (ContributionOffsets[i])
Out.EmitIntValue(E.Contributions[i].Length, 4);
return std::error_code(); return std::error_code();
} }