[llvm] [BOLT][DWARF][NFC] Remove unnecessary SectionOffset (PR #97841)
Sayhaan Siddiqui via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 5 11:01:58 PDT 2024
https://github.com/sayhaan updated https://github.com/llvm/llvm-project/pull/97841
>From 6f0dfe61e43a62a4727f679b3e33232d223215d8 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Fri, 28 Jun 2024 12:10:33 -0700
Subject: [PATCH 1/2] Remove unnecessary SectionOffset
Summary:
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: https://phabricator.intern.facebook.com/D59175270
---
bolt/include/bolt/Core/DebugData.h | 4 ----
bolt/lib/Core/DebugData.cpp | 15 +++++++++------
2 files changed, 9 insertions(+), 10 deletions(-)
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..dbf36ea3328a4 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,15 +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;
}
void DebugRangesSectionWriter::appendToRangeBuffer(
@@ -327,7 +331,6 @@ void DebugRangeListsSectionWriter::finalizeSection() {
*RangesStream << *Header;
*RangesStream << *CUArrayBuffer;
*RangesStream << *CUBodyBuffer;
- SectionOffset = RangesBuffer->size();
}
void DebugRangeListsSectionWriter::initSection(DWARFUnit &Unit) {
>From c436409d51efbacc7720222763665955323e0092 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Fri, 5 Jul 2024 10:55:05 -0700
Subject: [PATCH 2/2] Fix duplicated function
---
bolt/lib/Core/DebugData.cpp | 6 ------
1 file changed, 6 deletions(-)
diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp
index dbf36ea3328a4..579af3bce4eb8 100644
--- a/bolt/lib/Core/DebugData.cpp
+++ b/bolt/lib/Core/DebugData.cpp
@@ -181,12 +181,6 @@ void DebugRangesSectionWriter::appendToRangeBuffer(
*RangesStream << CUBuffer;
}
-void DebugRangesSectionWriter::appendToRangeBuffer(
- const DebugBufferVector &CUBuffer) {
- *RangesStream << CUBuffer;
- SectionOffset = RangesBuffer->size();
-}
-
DebugAddrWriter *DebugRangeListsSectionWriter::AddrWriter = nullptr;
uint64_t DebugRangeListsSectionWriter::addRanges(
More information about the llvm-commits
mailing list