[llvm] [BOLT][DWARF][NFC] Remove unnecessary SectionOffset (PR #97841)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 5 11:05:24 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-bolt
Author: Sayhaan Siddiqui (sayhaan)
<details>
<summary>Changes</summary>
Removes unnecessary SectionOffset variable from DebugData.
---
Full diff: https://github.com/llvm/llvm-project/pull/97841.diff
2 Files Affected:
- (modified) bolt/include/bolt/Core/DebugData.h (-4)
- (modified) bolt/lib/Core/DebugData.cpp (+4-7)
``````````diff
diff --git a/bolt/include/bolt/Core/DebugData.h b/bolt/include/bolt/Core/DebugData.h
index 144433ac78a37..cdcc8cd61f4fa 100644
--- a/bolt/include/bolt/Core/DebugData.h
+++ b/bolt/include/bolt/Core/DebugData.h
@@ -233,10 +233,6 @@ class DebugRangesSectionWriter {
std::mutex WriterMutex;
- /// Current offset in the section (updated as new entries are written).
- /// Starts with 16 since the first 16 bytes are reserved for an empty range.
- uint32_t SectionOffset{0};
-
/// Offset of an empty address ranges list.
static constexpr uint64_t EmptyRangesOffset{0};
diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp
index 08d4c45aac791..579af3bce4eb8 100644
--- a/bolt/lib/Core/DebugData.cpp
+++ b/bolt/lib/Core/DebugData.cpp
@@ -138,8 +138,7 @@ DebugRangesSectionWriter::DebugRangesSectionWriter() {
RangesStream = std::make_unique<raw_svector_ostream>(*RangesBuffer);
// Add an empty range as the first entry;
- SectionOffset +=
- writeAddressRanges(*RangesStream.get(), DebugAddressRangesVector{});
+ writeAddressRanges(*RangesStream.get(), DebugAddressRangesVector{});
Kind = RangesWriterKind::DebugRangesWriter;
}
@@ -166,21 +165,20 @@ uint64_t DebugRangesSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
// Reading the SectionOffset and updating it should be atomic to guarantee
// unique and correct offsets in patches.
std::lock_guard<std::mutex> Lock(WriterMutex);
- const uint32_t EntryOffset = SectionOffset;
- SectionOffset += writeAddressRanges(*RangesStream.get(), Ranges);
+ const uint32_t EntryOffset = RangesBuffer->size();
+ writeAddressRanges(*RangesStream.get(), Ranges);
return EntryOffset;
}
uint64_t DebugRangesSectionWriter::getSectionOffset() {
std::lock_guard<std::mutex> Lock(WriterMutex);
- return SectionOffset;
+ return RangesBuffer->size();
}
void DebugRangesSectionWriter::appendToRangeBuffer(
const DebugBufferVector &CUBuffer) {
*RangesStream << CUBuffer;
- SectionOffset = RangesBuffer->size();
}
DebugAddrWriter *DebugRangeListsSectionWriter::AddrWriter = nullptr;
@@ -327,7 +325,6 @@ void DebugRangeListsSectionWriter::finalizeSection() {
*RangesStream << *Header;
*RangesStream << *CUArrayBuffer;
*RangesStream << *CUBodyBuffer;
- SectionOffset = RangesBuffer->size();
}
void DebugRangeListsSectionWriter::initSection(DWARFUnit &Unit) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/97841
More information about the llvm-commits
mailing list