[llvm] a2404bc - [AppleAccelTable][NFC] Make FormParams member of AppleAccelTable

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 8 08:16:26 PDT 2023


Author: Felipe de Azevedo Piovezan
Date: 2023-06-08T11:15:56-04:00
New Revision: a2404bc3231fe9a70c843016a66e23aa246b8f3c

URL: https://github.com/llvm/llvm-project/commit/a2404bc3231fe9a70c843016a66e23aa246b8f3c
DIFF: https://github.com/llvm/llvm-project/commit/a2404bc3231fe9a70c843016a66e23aa246b8f3c.diff

LOG: [AppleAccelTable][NFC] Make FormParams member of AppleAccelTable

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 D151989

Differential Revision: https://reviews.llvm.org/D152156

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
index cc54e6d93cc4c..a1f50110a7d57 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFAcceleratorTable.h
@@ -105,6 +105,7 @@ class AppleAcceleratorTable : public DWARFAcceleratorTable {
 
   Header Hdr;
   HeaderData HdrData;
+  dwarf::FormParams FormParams;
   bool IsValid = false;
 
   /// Returns true if we should continue scanning for entries or false if we've

diff  --git a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
index 5b6e21b091231..89b4cb9cfa201 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp
@@ -54,6 +54,7 @@ Error AppleAcceleratorTable::extract() {
   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).
@@ -113,7 +114,6 @@ std::pair<uint64_t, dwarf::Tag>
 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);
@@ -162,7 +162,6 @@ std::optional<uint64_t> AppleAcceleratorTable::HeaderData::extractOffset(
 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.");
@@ -264,11 +263,8 @@ AppleAcceleratorTable::Entry::Entry(
 
 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>


        


More information about the llvm-commits mailing list