diff --git a/bolt/include/bolt/Core/DebugData.h b/bolt/include/bolt/Core/DebugData.h --- a/bolt/include/bolt/Core/DebugData.h +++ b/bolt/include/bolt/Core/DebugData.h @@ -718,8 +718,11 @@ std::unique_ptr Buffer; std::unique_ptr Stream; }; - /// Map original unit abbrev offset to abbreviations data. - std::map UnitsAbbrevData; + /// Map original unit to abbreviations data. + std::unordered_map UnitsAbbrevData; + + /// Map from Hash Signature to AbbrevData. + std::unordered_map> AbbrevDataCache; /// Attributes substitution (patch) information. struct PatchInfo { @@ -786,10 +789,8 @@ /// Return an offset in the finalized abbrev section corresponding to CU/TU. uint64_t getAbbreviationsOffsetForUnit(const DWARFUnit &Unit) { assert(!DWOId && "offsets are tracked for non-DWO units only"); - assert(UnitsAbbrevData.find(Unit.getAbbreviationsOffset()) != - UnitsAbbrevData.end() && - "no abbrev data found for unit"); - return UnitsAbbrevData[Unit.getAbbreviationsOffset()].Offset; + assert(UnitsAbbrevData.count(&Unit) && "no abbrev data found for unit"); + return UnitsAbbrevData[&Unit]->Offset; } }; diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp --- a/bolt/lib/Core/DebugData.cpp +++ b/bolt/lib/Core/DebugData.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/EndianStream.h" #include "llvm/Support/LEB128.h" +#include "llvm/Support/SHA1.h" #include #include #include @@ -693,20 +694,30 @@ if (!Abbrevs) return; - // Multiple units may share the same abbreviations. Only add abbreviations - // for the first unit and reuse them. - const uint64_t AbbrevOffset = Unit.getAbbreviationsOffset(); - if (UnitsAbbrevData.find(AbbrevOffset) != UnitsAbbrevData.end()) - return; + const PatchesTy &UnitPatches = Patches[&Unit]; - AbbrevData &UnitData = UnitsAbbrevData[AbbrevOffset]; + // We are duplicating abbrev sections, to handle the case where for one CU we + // modify it, but for another we don't. + auto UnitDataPtr = std::make_unique(); + AbbrevData &UnitData = *UnitDataPtr.get(); UnitData.Buffer = std::make_unique(); UnitData.Stream = std::make_unique(*UnitData.Buffer); - - const PatchesTy &UnitPatches = Patches[&Unit]; - raw_svector_ostream &OS = *UnitData.Stream.get(); + // Returns true if AbbrevData is re-used, false otherwise. + auto hashAndAddAbbrev = [&](StringRef AbbrevData) -> bool { + llvm::SHA1 Hasher; + Hasher.update(AbbrevData); + std::string Key = Hasher.final().str(); + auto Iter = AbbrevDataCache.find(Key); + if (Iter != AbbrevDataCache.end()) { + UnitsAbbrevData[&Unit] = Iter->second.get(); + return true; + } + AbbrevDataCache[Key] = std::move(UnitDataPtr); + UnitsAbbrevData[&Unit] = &UnitData; + return false; + }; // Take a fast path if there are no patches to apply. Simply copy the original // contents. if (UnitPatches.empty()) { @@ -755,9 +766,10 @@ AbbrevContents = AbbrevSectionContents; } - OS.reserveExtraSpace(AbbrevContents.size()); - OS << AbbrevContents; - + if (!hashAndAddAbbrev(AbbrevContents)) { + OS.reserveExtraSpace(AbbrevContents.size()); + OS << AbbrevContents; + } return; } @@ -797,9 +809,13 @@ encodeULEB128(0, OS); } encodeULEB128(0, OS); + + hashAndAddAbbrev(OS.str()); } std::unique_ptr DebugAbbrevWriter::finalize() { + // Used to create determinism for writing out abbrevs. + std::vector Abbrevs; if (DWOId) { // We expect abbrev_offset to always be zero for DWO units as there // should be one CU per DWO, and TUs should share the same abbreviation @@ -817,33 +833,40 @@ } } + DWARFUnit *Unit = Context.getDWOCompileUnitForHash(*DWOId); // Issue abbreviations for the DWO CU only. - addUnitAbbreviations(*Context.getDWOCompileUnitForHash(*DWOId)); + addUnitAbbreviations(*Unit); + AbbrevData *Abbrev = UnitsAbbrevData[Unit]; + Abbrevs.push_back(Abbrev); } else { + Abbrevs.reserve(Context.getNumCompileUnits() + Context.getNumTypeUnits()); + std::unordered_set ProcessedAbbrevs; // Add abbreviations from compile and type non-DWO units. - for (const std::unique_ptr &Unit : Context.normal_units()) + for (const std::unique_ptr &Unit : Context.normal_units()) { addUnitAbbreviations(*Unit); + AbbrevData *Abbrev = UnitsAbbrevData[Unit.get()]; + if (!ProcessedAbbrevs.insert(Abbrev).second) + continue; + Abbrevs.push_back(Abbrev); + } } DebugBufferVector ReturnBuffer; - // Pre-calculate the total size of abbrev section. uint64_t Size = 0; - for (const auto &KV : UnitsAbbrevData) { - const AbbrevData &UnitData = KV.second; - Size += UnitData.Buffer->size(); - } + for (const AbbrevData *UnitData : Abbrevs) + Size += UnitData->Buffer->size(); + ReturnBuffer.reserve(Size); uint64_t Pos = 0; - for (auto &KV : UnitsAbbrevData) { - AbbrevData &UnitData = KV.second; - ReturnBuffer.append(*UnitData.Buffer); - UnitData.Offset = Pos; - Pos += UnitData.Buffer->size(); - - UnitData.Buffer.reset(); - UnitData.Stream.reset(); + for (AbbrevData *UnitData : Abbrevs) { + ReturnBuffer.append(*UnitData->Buffer); + UnitData->Offset = Pos; + Pos += UnitData->Buffer->size(); + + UnitData->Buffer.reset(); + UnitData->Stream.reset(); } return std::make_unique(ReturnBuffer); diff --git a/bolt/test/X86/Inputs/dwarfdump-gdbindex-v7.elf-x86-64.yaml b/bolt/test/X86/Inputs/dwarfdump-gdbindex-v7.elf-x86-64.yaml new file mode 100644 --- /dev/null +++ b/bolt/test/X86/Inputs/dwarfdump-gdbindex-v7.elf-x86-64.yaml @@ -0,0 +1,134 @@ +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_EXEC + Machine: EM_X86_64 +ProgramHeaders: + - Type: PT_LOAD + Flags: [ PF_X, PF_R ] + FirstSec: .text + LastSec: .eh_frame + VAddr: 0x400000 + Align: 0x1000 + - Type: PT_LOAD + Flags: [ PF_W, PF_R ] + FirstSec: .data + LastSec: .bss + VAddr: 0x401000 + Align: 0x1000 + - Type: PT_GNU_STACK + Flags: [ PF_W, PF_R ] + Align: 0x0 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Address: 0x4000E8 + AddressAlign: 0x1 + Content: 554889E5B8000000005DC3554889E5B8000000005DC3 + - Name: .eh_frame + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC ] + Address: 0x400100 + AddressAlign: 0x8 + Content: 1400000000000000017A5200017810011B0C0708900100001C0000001C000000C8FFFFFF0B00000000410E108602430D06460C07080000001C0000003C000000B3FFFFFF0B00000000410E108602430D06460C0708000000 + - Name: .data + Type: SHT_PROGBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x401000 + AddressAlign: 0x1 + Offset: 0x1000 + - Name: .bss + Type: SHT_NOBITS + Flags: [ SHF_WRITE, SHF_ALLOC ] + Address: 0x401000 + AddressAlign: 0x1 + - Name: .debug_addr + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: E800400000000000F300400000000000 + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 300000000400000000000801E8004000000000000B00000000000000000000000000000009000000000000002FBA8B66E3F5A8E03000000004001A0000000801F3004000000000000B000000000000003B000000260000000900000008000000C31C2F0C7709348D + - Name: .debug_abbrev + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 011100110112071017B0420E1B0EB44219B34217B14207000000011100110112071017B0420E1B0EB44219B34217B14207000000 + - Name: .debug_line + Type: SHT_PROGBITS + AddressAlign: 0x1 + Content: 3700000002001F0000000101FB0E0D00010101010000000100000100746573742E6370700000000000000902E800400000000000014A0207000101380000000200200000000101FB0E0D0001010101000000010000010074657374322E6370700000000000000902F300400000000000014A0207000101 + - Name: .comment + Type: SHT_PROGBITS + Flags: [ SHF_MERGE, SHF_STRINGS ] + AddressAlign: 0x1 + EntSize: 0x1 + Content: 004743433A20285562756E747520352E342E302D367562756E7475317E31362E30342E322920352E342E3020323031363036303900 + - Name: .note.gnu.gold-version + Type: SHT_NOTE + AddressAlign: 0x4 + Notes: + - Name: GNU + Desc: 676F6C6420312E3131 + Type: NT_TASKSTRUCT + - Name: .gdb_index + Type: SHT_PROGBITS + AddressAlign: 0x4 + Offset: 0x1748 + Content: 0700000018000000380000003800000060000000602000000000000000000000340000000000000034000000000000003400000000000000E800400000000000F30040000000000000000000F300400000000000FE00400000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001D0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000022000000080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002600000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000300200000000000090010000900100000001000030006D61696E00696E74006D61696E3200 + - Type: SectionHeaderTable + Sections: + - Name: .text + - Name: .eh_frame + - Name: .data + - Name: .bss + - Name: .debug_addr + - Name: .debug_info + - Name: .debug_abbrev + - Name: .debug_line + - Name: .debug_str + - Name: .comment + - Name: .gdb_index + - Name: .note.gnu.gold-version + - Name: .symtab + - Name: .strtab + - Name: .shstrtab +Symbols: + - Name: test.cpp + Type: STT_FILE + Index: SHN_ABS + - Name: test2.cpp + Type: STT_FILE + Index: SHN_ABS + - Name: main + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x4000E8 + Size: 0xB + - Name: _Z5main2v + Type: STT_FUNC + Section: .text + Binding: STB_GLOBAL + Value: 0x4000F3 + Size: 0xB + - Name: _edata + Index: SHN_ABS + Binding: STB_GLOBAL + Value: 0x401000 + - Name: __bss_start + Index: SHN_ABS + Binding: STB_GLOBAL + Value: 0x401000 + - Name: _end + Index: SHN_ABS + Binding: STB_GLOBAL + Value: 0x401000 +DWARF: + debug_str: + - test.dwo + - '/home/umb/tests/93splitdebug' + - test2.dwo +... diff --git a/bolt/test/X86/shared-abbrev.s b/bolt/test/X86/shared-abbrev.s new file mode 100644 --- /dev/null +++ b/bolt/test/X86/shared-abbrev.s @@ -0,0 +1,121 @@ +# RUN: rm -rf %t +# RUN: mkdir %t +# RUN: llvm-mc -filetype=obj -triple=x86_64 -dwarf-version=4 %s -o %t/shared-abbrev.o +# RUN: %clang %cflags %t/shared-abbrev.o -o %t/shared-abbrev.exe +# RUN: llvm-bolt %t/shared-abbrev.exe -o %t/shared-abbrev.exe.bolt -update-debug-sections +# RUN: llvm-dwarfdump --debug-info %t/shared-abbrev.exe.bolt | FileCheck %s + +# CHECK: 0x00000000: +# CHECK-SAME: abbr_offset = 0x0000 +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_compile_unit +# CHECK-NEXT: DW_AT_stmt_list +# CHECK-NEXT: DW_AT_low_pc +# CHECK-NEXT: DW_AT_ranges +# CHECK: 0x0000001d: +# CHECK-SAME: abbr_offset = 0x0017 +# CHECK-EMPTY: +# CHECK: DW_TAG_compile_unit +# CHECK-NEXT: DW_AT_stmt_list +# CHECK-NEXT: DW_AT_low_pc +# CHECK-NEXT: DW_AT_ranges +# CHECK: 0x0000003a: +# CHECK-SAME: abbr_offset = 0x0000 +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_compile_unit +# CHECK-NEXT: DW_AT_stmt_list +# CHECK-NEXT: DW_AT_low_pc +# CHECK-NEXT: DW_AT_ranges + + .text + .file "main.cpp" + .globl main # -- Begin function main + .p2align 4, 0x90 + .type main,@function +main: # @main +.Lfunc_begin0: + .file 1 "test" "main.cpp" + .loc 1 1 0 # main.cpp:1:0 + .cfi_startproc + .cfi_def_cfa %rsp, 8 + retq +.Ltmp1: +.Lfunc_end0: + .size main, .Lfunc_end0-main + .cfi_endproc + # -- End function + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 7 # DW_FORM_data8 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 85 # DW_AT_ranges + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + .section .debug_info,"",@progbits +.Lcu_begin0: + .long .Ldebug_info_end0-.Ldebug_info_start0 # Length of Unit +.Ldebug_info_start0: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 2 # Abbrev [2] DW_TAG_compile_unit + .long .Lline_table_start0 # DW_AT_stmt_list + .quad 0 # DW_AT_low_pc + .byte 0 # End Of Children Mark + .long .Ldebug_ranges0 # DW_AT_ranges --- end manual -- +.Ldebug_info_end0: + + # Second CU table. + .long .Ldebug_info_end1-.Ldebug_info_start1 # Length of Unit +.Ldebug_info_start1: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] DW_TAG_compile_unit + .long .Lline_table_start0 # DW_AT_stmt_list + .quad .Lfunc_begin0 # DW_AT_low_pc + .quad .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 0 # End Of Children Mark +.Ldebug_info_end1: + + # Third CU table. + .long .Ldebug_info_end2-.Ldebug_info_start2 # Length of Unit +.Ldebug_info_start2: + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 2 # Abbrev [2] DW_TAG_compile_unit + .long .Lline_table_start0 # DW_AT_stmt_list + .quad 0 # DW_AT_low_pc + .byte 0 # End Of Children Mark + .long .Ldebug_ranges0 # DW_AT_ranges --- end manual -- +.Ldebug_info_end2: + .section .debug_ranges,"",@progbits +.Ldebug_ranges0: + .quad .Lfunc_begin0 + .quad .Lfunc_end0 + .quad .Lfunc_begin0 + .quad .Lfunc_end0 + .quad 0 + .quad 0 + .section ".note.GNU-stack","",@progbits + .addrsig + .section .debug_line,"",@progbits +.Lline_table_start0: