[PATCH] D152156: [AppleAccelTable][NFC] Make FormParams member of AppleAccelTable

Felipe de Azevedo Piovezan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 5 06:44:53 PDT 2023


fdeazeve created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
fdeazeve requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

These are used throughout the class and are recreated every time they are used.
To prevent the risk of it being created incorrectly in different places, we
create it once and in the earliest moment possible: when the table is extracted.

Depends on D152155 <https://reviews.llvm.org/D152155>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152156

Files:
  llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
  llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp


Index: llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
===================================================================
--- llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -54,6 +54,7 @@
   Hdr.BucketCount = AccelSection.getU32(&Offset);
   Hdr.HashCount = AccelSection.getU32(&Offset);
   Hdr.HeaderDataLength = AccelSection.getU32(&Offset);
+  FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32};
 
   // Check that we can read all the hashes and offsets from the
   // section (see SourceLevelDebugging.rst for the structure of the index).
@@ -111,7 +112,6 @@
 AppleAcceleratorTable::readAtoms(uint64_t *HashDataOffset) {
   uint64_t DieOffset = dwarf::DW_INVALID_OFFSET;
   dwarf::Tag DieTag = dwarf::DW_TAG_null;
-  dwarf::FormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32};
 
   for (auto Atom : getAtomsDesc()) {
     DWARFFormValue FormValue(Atom.second);
@@ -160,7 +160,6 @@
 bool AppleAcceleratorTable::dumpName(ScopedPrinter &W,
                                      SmallVectorImpl<DWARFFormValue> &AtomForms,
                                      uint64_t *DataOffset) const {
-  dwarf::FormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32};
   uint64_t NameOffset = *DataOffset;
   if (!AccelSection.isValidOffsetForDataOfSize(*DataOffset, 4)) {
     W.printString("Incorrectly terminated list.");
@@ -262,11 +261,8 @@
 
 void AppleAcceleratorTable::Entry::extract(
     const AppleAcceleratorTable &AccelTable, uint64_t *Offset) {
-
-  dwarf::FormParams FormParams = {AccelTable.Hdr.Version, 0,
-                                  dwarf::DwarfFormat::DWARF32};
   for (auto &Atom : Values)
-    Atom.extractValue(AccelTable.AccelSection, Offset, FormParams);
+    Atom.extractValue(AccelTable.AccelSection, Offset, AccelTable.FormParams);
 }
 
 std::optional<DWARFFormValue>
Index: llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
===================================================================
--- llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
+++ llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
@@ -105,6 +105,7 @@
 
   Header Hdr;
   HeaderData HdrData;
+  dwarf::FormParams FormParams;
   bool IsValid = false;
 
   /// Returns true if we should continue scanning for entries or false if we've


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D152156.528412.patch
Type: text/x-patch
Size: 2356 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230605/53d81fd5/attachment.bin>


More information about the llvm-commits mailing list