[llvm] [BOLT][DWARF][NFC] Refactor address writers (PR #98094)
Sayhaan Siddiqui via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 11 16:06:40 PDT 2024
================
@@ -504,55 +502,44 @@ void DebugAddrWriterDwarf5::update(DIEBuilder &DIEBlder, DWARFUnit &CU) {
Endian == llvm::endianness::little, 0);
DWARFDebugAddrTable AddrTable;
DIDumpOptions DumpOpts;
- constexpr uint32_t HeaderSize = 8;
- const uint64_t CUID = getCUID(CU);
- const uint8_t AddrSize = CU.getAddressByteSize();
- auto AMIter = AddressMaps.find(CUID);
// A case where CU has entry in .debug_addr, but we don't modify addresses
// for it.
- if (AMIter == AddressMaps.end()) {
- AMIter = AddressMaps.insert({CUID, AddressForDWOCU()}).first;
- std::optional<uint64_t> BaseOffset = CU.getAddrOffsetSectionBase();
- if (!BaseOffset)
- return;
+ if (Map.begin() == Map.end()) {
+ if (!AddrOffsetSectionBase)
+ return std::nullopt;
// Address base offset is to the first entry.
// The size of header is 8 bytes.
- uint64_t Offset = *BaseOffset - HeaderSize;
+ uint64_t Offset = *AddrOffsetSectionBase - HeaderSize;
auto Iter = UnmodifiedAddressOffsets.find(Offset);
- if (Iter != UnmodifiedAddressOffsets.end()) {
- updateAddressBase(DIEBlder, *this, CU, Iter->getSecond());
- return;
- }
- UnmodifiedAddressOffsets[Offset] = Buffer->size() + HeaderSize;
- if (Error Err = AddrTable.extract(AddrData, &Offset, 5, AddrSize,
+ if (Iter != UnmodifiedAddressOffsets.end())
+ return Iter->second;
+ UnmodifiedAddressOffsets[Offset] = BufferSize;
----------------
sayhaan wrote:
We set UnmodifiedAddressOffsets[Offset] and then return it if we find the Offset in the map later. When we return we call updateAddrBase which adds the HeaderSize, so it's not necessary to add it here.
https://github.com/llvm/llvm-project/pull/98094
More information about the llvm-commits
mailing list