Skip to content

Commit f137be3

Browse files
authored
[BOLT][DWARF][NFC] Remove unnecessary SectionOffset (llvm#97841)
Removes unnecessary SectionOffset variable from DebugData.
1 parent a40daa3 commit f137be3

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

bolt/include/bolt/Core/DebugData.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,10 +233,6 @@ class DebugRangesSectionWriter {
233233

234234
std::mutex WriterMutex;
235235

236-
/// Current offset in the section (updated as new entries are written).
237-
/// Starts with 16 since the first 16 bytes are reserved for an empty range.
238-
uint32_t SectionOffset{0};
239-
240236
/// Offset of an empty address ranges list.
241237
static constexpr uint64_t EmptyRangesOffset{0};
242238

bolt/lib/Core/DebugData.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ DebugRangesSectionWriter::DebugRangesSectionWriter() {
138138
RangesStream = std::make_unique<raw_svector_ostream>(*RangesBuffer);
139139

140140
// Add an empty range as the first entry;
141-
SectionOffset +=
142-
writeAddressRanges(*RangesStream.get(), DebugAddressRangesVector{});
141+
writeAddressRanges(*RangesStream.get(), DebugAddressRangesVector{});
143142
Kind = RangesWriterKind::DebugRangesWriter;
144143
}
145144

@@ -166,21 +165,20 @@ uint64_t DebugRangesSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
166165
// Reading the SectionOffset and updating it should be atomic to guarantee
167166
// unique and correct offsets in patches.
168167
std::lock_guard<std::mutex> Lock(WriterMutex);
169-
const uint32_t EntryOffset = SectionOffset;
170-
SectionOffset += writeAddressRanges(*RangesStream.get(), Ranges);
168+
const uint32_t EntryOffset = RangesBuffer->size();
169+
writeAddressRanges(*RangesStream.get(), Ranges);
171170

172171
return EntryOffset;
173172
}
174173

175174
uint64_t DebugRangesSectionWriter::getSectionOffset() {
176175
std::lock_guard<std::mutex> Lock(WriterMutex);
177-
return SectionOffset;
176+
return RangesBuffer->size();
178177
}
179178

180179
void DebugRangesSectionWriter::appendToRangeBuffer(
181180
const DebugBufferVector &CUBuffer) {
182181
*RangesStream << CUBuffer;
183-
SectionOffset = RangesBuffer->size();
184182
}
185183

186184
DebugAddrWriter *DebugRangeListsSectionWriter::AddrWriter = nullptr;
@@ -327,7 +325,6 @@ void DebugRangeListsSectionWriter::finalizeSection() {
327325
*RangesStream << *Header;
328326
*RangesStream << *CUArrayBuffer;
329327
*RangesStream << *CUBodyBuffer;
330-
SectionOffset = RangesBuffer->size();
331328
}
332329

333330
void DebugRangeListsSectionWriter::initSection(DWARFUnit &Unit) {

0 commit comments

Comments
 (0)