From 058e527434aeb61ee6f72d2d460123440726a7df Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan Date: Thu, 21 Dec 2023 16:10:30 -0300 Subject: [PATCH] [AccelTable][NFC] Fix typos and duplicated code (#76155) Renaming a member variable from "Endoding" to "Encoding". Also replace inlined code for "isNormalized" with a call to the function, so that if the definition of normalization ever changes, we only need to change the one place. --- llvm/include/llvm/CodeGen/AccelTable.h | 8 +++----- llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp | 4 ++-- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/llvm/include/llvm/CodeGen/AccelTable.h b/llvm/include/llvm/CodeGen/AccelTable.h index af874aa5e91a32..6eb09f32f9f951 100644 --- a/llvm/include/llvm/CodeGen/AccelTable.h +++ b/llvm/include/llvm/CodeGen/AccelTable.h @@ -270,16 +270,14 @@ class DWARF5AccelTableData : public AccelTableData { #endif uint64_t getDieOffset() const { - assert(std::holds_alternative(OffsetVal) && - "Accessing DIE Offset before normalizing."); + assert(isNormalized() && "Accessing DIE Offset before normalizing."); return std::get(OffsetVal); } unsigned getDieTag() const { return DieTag; } unsigned getUnitID() const { return UnitID; } bool isTU() const { return IsTU; } void normalizeDIEToOffset() { - assert(std::holds_alternative(OffsetVal) && - "Accessing offset after normalizing."); + assert(!isNormalized() && "Accessing offset after normalizing."); OffsetVal = std::get(OffsetVal)->getOffset(); } bool isNormalized() const { @@ -309,7 +307,7 @@ class DWARF5AccelTable : public AccelTable { public: struct UnitIndexAndEncoding { unsigned Index; - DWARF5AccelTableData::AttributeEncoding Endoding; + DWARF5AccelTableData::AttributeEncoding Encoding; }; /// Returns type units that were constructed. const TUVectorTy &getTypeUnitsSymbols() { return TUSymbolsOrHashes; } diff --git a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp index d6f487c18b0301..30ea7eef3a12ba 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp @@ -412,7 +412,7 @@ static uint32_t constructAbbreviationTag( const std::optional &EntryRet) { uint32_t AbbrvTag = 0; if (EntryRet) - AbbrvTag |= 1 << EntryRet->Endoding.Index; + AbbrvTag |= 1 << EntryRet->Encoding.Index; AbbrvTag |= 1 << dwarf::DW_IDX_die_offset; AbbrvTag |= Tag << LowerBitSize; return AbbrvTag; @@ -429,7 +429,7 @@ void Dwarf5AccelTableWriter::populateAbbrevsMap() { if (Abbreviations.count(AbbrvTag) == 0) { SmallVector UA; if (EntryRet) - UA.push_back(EntryRet->Endoding); + UA.push_back(EntryRet->Encoding); UA.push_back({dwarf::DW_IDX_die_offset, dwarf::DW_FORM_ref4}); Abbreviations.try_emplace(AbbrvTag, UA); }