[llvm] [BOLT][DWARF] Refactor DebugStrOffsetsWriter (PR #82548)

Alexander Yermolovich via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 21 14:50:18 PST 2024


https://github.com/ayermolo created https://github.com/llvm/llvm-project/pull/82548

Refactored clearning data structures in DebugStrOffsetsWriter into clear() function and made initialize() public. This is for https://github.com/llvm/llvm-project/pull/81062.

>From ceb317851a565f8dc9ed41699cb18b5c56fdc748 Mon Sep 17 00:00:00 2001
From: Alexander Yermolovich <ayermolo at meta.com>
Date: Wed, 21 Feb 2024 14:46:28 -0800
Subject: [PATCH] [BOLT][DWARF] Refactor DebugStrOffsetsWriter

Refactored clearning data structures in DebugStrOffsetsWriter into clear()
function and made initialize() public. This is for
https://github.com/llvm/llvm-project/pull/81062.
---
 bolt/include/bolt/Core/DebugData.h | 8 +++++++-
 bolt/lib/Core/DebugData.cpp        | 3 +--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/bolt/include/bolt/Core/DebugData.h b/bolt/include/bolt/Core/DebugData.h
index 31a636ba2ce653..48b813a4ca11fe 100644
--- a/bolt/include/bolt/Core/DebugData.h
+++ b/bolt/include/bolt/Core/DebugData.h
@@ -450,10 +450,16 @@ class DebugStrOffsetsWriter {
     return std::move(StrOffsetsBuffer);
   }
 
-private:
   /// Initializes Buffer and Stream.
   void initialize(DWARFUnit &Unit);
 
+  /// Clear data.
+  void clear() {
+    IndexToAddressMap.clear();
+    StrOffsets.clear();
+  }
+
+private:
   std::unique_ptr<DebugStrOffsetsBufferVector> StrOffsetsBuffer;
   std::unique_ptr<raw_svector_ostream> StrOffsetsStream;
   std::map<uint32_t, uint32_t> IndexToAddressMap;
diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp
index 8c3f6bd2052f9e..76116946f5dbfb 100644
--- a/bolt/lib/Core/DebugData.cpp
+++ b/bolt/lib/Core/DebugData.cpp
@@ -916,8 +916,7 @@ void DebugStrOffsetsWriter::finalizeSection(DWARFUnit &Unit,
   }
 
   StrOffsetSectionWasModified = false;
-  IndexToAddressMap.clear();
-  StrOffsets.clear();
+  clear();
 }
 
 void DebugStrWriter::create() {



More information about the llvm-commits mailing list