[llvm] [RFC][BOLT] A New Parallel DWARF Processing Approach in BOLT (PR #195058)

via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 04:02:10 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- bolt/include/bolt/Core/DIEBuilder.h bolt/include/bolt/Core/DebugData.h bolt/include/bolt/Core/DebugNames.h bolt/include/bolt/Rewrite/DWARFRewriter.h bolt/lib/Core/DIEBuilder.cpp bolt/lib/Core/DebugData.cpp bolt/lib/Core/DebugNames.cpp bolt/lib/Rewrite/DWARFRewriter.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/bolt/include/bolt/Core/DIEBuilder.h b/bolt/include/bolt/Core/DIEBuilder.h
index 7ba196607..dc36d979a 100644
--- a/bolt/include/bolt/Core/DIEBuilder.h
+++ b/bolt/include/bolt/Core/DIEBuilder.h
@@ -340,10 +340,11 @@ public:
   void assignAbbrev(DIEAbbrev &Abbrev);
   void syncAbbrevTableFrom(const DIEBuilder &SrcBuilder);
 
-  /// Set the base offset for CU emission, used by the incremental merge pipeline
-  void setUnitOffsetBases(uint64_t Base) { 
-    DebugNamesUnitSize = Base; 
-    UnitSize = Base; 
+  /// Set the base offset for CU emission, used by the incremental merge
+  /// pipeline
+  void setUnitOffsetBases(uint64_t Base) {
+    DebugNamesUnitSize = Base;
+    UnitSize = Base;
   }
 
   /// Finish current DIE construction.
@@ -393,18 +394,18 @@ public:
     return Die->deleteValue(Attribute);
   }
   /// Updates DWO Name and Compilation directory for Skeleton CU \p Unit.
-  std::string updateDWONameCompDir(DebugStrOffsetsWriter &StrOffstsWriter,
-                                   DebugStrWriter &StrWriter,
-                                   DWARFUnit &SkeletonCU,
-                                   std::optional<StringRef> DwarfOutputPath,
-                                   std::optional<StringRef> DWONameToUse,
-                                   std::unordered_map<uint64_t, std::string> &DWOIDToName);
+  std::string
+  updateDWONameCompDir(DebugStrOffsetsWriter &StrOffstsWriter,
+                       DebugStrWriter &StrWriter, DWARFUnit &SkeletonCU,
+                       std::optional<StringRef> DwarfOutputPath,
+                       std::optional<StringRef> DWONameToUse,
+                       std::unordered_map<uint64_t, std::string> &DWOIDToName);
   /// Updates DWO Name and Compilation directory for Type Units.
-  void updateDWONameCompDirForTypes(DebugStrOffsetsWriter &StrOffstsWriter,
-                                    DebugStrWriter &StrWriter, DWARFUnit &Unit,
-                                    std::optional<StringRef> DwarfOutputPath,
-                                    const StringRef DWOName,
-                                    std::unordered_map<uint64_t, std::string> &DWOIDToName);
+  void updateDWONameCompDirForTypes(
+      DebugStrOffsetsWriter &StrOffstsWriter, DebugStrWriter &StrWriter,
+      DWARFUnit &Unit, std::optional<StringRef> DwarfOutputPath,
+      const StringRef DWOName,
+      std::unordered_map<uint64_t, std::string> &DWOIDToName);
 };
 } // namespace bolt
 } // namespace llvm
diff --git a/bolt/include/bolt/Core/DebugData.h b/bolt/include/bolt/Core/DebugData.h
index 1c5334b2d..ae351c5b7 100644
--- a/bolt/include/bolt/Core/DebugData.h
+++ b/bolt/include/bolt/Core/DebugData.h
@@ -573,7 +573,7 @@ public:
 
   /// Returns the current size (in bytes) of the serialized location buffer.
   uint64_t getLocBufferSize() const { return LocBuffer->size(); }
-  
+
   /// Applies an additional base offset to all non-empty location list offsets
   /// recorded for this CU.
   void applyBase(DIEBuilder &DIEBldr, uint64_t Base);
@@ -587,7 +587,8 @@ public:
 protected:
   std::unique_ptr<DebugBufferVector> LocBuffer;
   std::unique_ptr<raw_svector_ostream> LocStream;
-  /// Current offset in this writer's local buffer (updated as new entries are written).
+  /// Current offset in this writer's local buffer (updated as new entries are
+  /// written).
   uint32_t LocSectionOffset{0};
   uint8_t DwarfVersion{4};
   LocWriterKind Kind{LocWriterKind::DebugLocWriter};
diff --git a/bolt/include/bolt/Rewrite/DWARFRewriter.h b/bolt/include/bolt/Rewrite/DWARFRewriter.h
index 6a64b3697..a80d1cd6d 100644
--- a/bolt/include/bolt/Rewrite/DWARFRewriter.h
+++ b/bolt/include/bolt/Rewrite/DWARFRewriter.h
@@ -183,9 +183,9 @@ private:
                              std::vector<uint64_t> SortedCU);
   void processMainBinaryCU(DWARFUnit &Unit, DIEBuilder &DIEBlder,
                            BucketLocalWriter &LocalWriter);
-      /// Patches the binary for DWARF address ranges (e.g. in functions and
-      /// lexical blocks) to be updated.
-      void updateDebugAddressRanges();
+  /// Patches the binary for DWARF address ranges (e.g. in functions and
+  /// lexical blocks) to be updated.
+  void updateDebugAddressRanges();
 
   /// DWARFDie contains a pointer to a DIE and hence gets invalidated once the
   /// embedded DIE is destroyed. This wrapper class stores a DIE internally and
diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp
index a363b197b..f6df2e36b 100644
--- a/bolt/lib/Core/DebugData.cpp
+++ b/bolt/lib/Core/DebugData.cpp
@@ -595,7 +595,7 @@ void DebugLocWriter::addList(DIEBuilder &DIEBldr, DIE &Die, DIEValue &AttrInfo,
   }
   LocStream->write_zeros(16);
   LocSectionOffset = LocBuffer->size();
-  LocListDebugInfoPatches.push_back({0xdeadbeee, EntryOffset}); 
+  LocListDebugInfoPatches.push_back({0xdeadbeee, EntryOffset});
   replaceLocValbyForm(DIEBldr, Die, AttrInfo, AttrInfo.getForm(), EntryOffset);
   LocListPatches.push_back({&Die, AttrInfo.getAttribute(), AttrInfo.getForm()});
 }
@@ -772,13 +772,12 @@ void DebugLoclistWriter::finalizeDWARF5(DIEBuilder &DIEBldr, DIE &Die) {
     DIEValue LocListBaseAttrInfo =
         Die.findAttribute(dwarf::DW_AT_loclists_base);
     if (LocListBaseAttrInfo.getType()) {
-      DIEBldr.replaceValue(
-          &Die, dwarf::DW_AT_loclists_base, LocListBaseAttrInfo.getForm(),
-          DIEInteger(LocalBase));
+      DIEBldr.replaceValue(&Die, dwarf::DW_AT_loclists_base,
+                           LocListBaseAttrInfo.getForm(),
+                           DIEInteger(LocalBase));
     } else {
       DIEBldr.addValue(&Die, dwarf::DW_AT_loclists_base,
-                       dwarf::DW_FORM_sec_offset,
-                       DIEInteger(LocalBase));
+                       dwarf::DW_FORM_sec_offset, DIEInteger(LocalBase));
     }
   }
   clearList(RelativeLocListOffsets);
diff --git a/bolt/lib/Core/DebugNames.cpp b/bolt/lib/Core/DebugNames.cpp
index 450e02ed3..fa2e45a73 100644
--- a/bolt/lib/Core/DebugNames.cpp
+++ b/bolt/lib/Core/DebugNames.cpp
@@ -12,8 +12,8 @@
 #include "llvm/DebugInfo/DWARF/LowLevel/DWARFExpression.h"
 #include "llvm/Support/EndianStream.h"
 #include "llvm/Support/LEB128.h"
-#include <cstdint>
 #include <climits>
+#include <cstdint>
 #include <optional>
 #include <tuple>
 
@@ -66,7 +66,7 @@ DWARF5AcceleratorTable::DWARF5AcceleratorTable(
   }
 }
 
-// 
+//
 void DWARF5AcceleratorTable::preAllocateUnits(DWARFContext &DwCtx) {
   // Collect all DWO IDs in deterministic order (by CU offset in .debug_info).
   // This is single-threaded, called before parallel process.

``````````

</details>


https://github.com/llvm/llvm-project/pull/195058


More information about the llvm-commits mailing list