Skip to content

Commit 3354eb4

Browse files
committed
changed naming, changed index
1 parent ac7ec22 commit 3354eb4

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

llvm/include/llvm/CodeGen/AccelTable.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ class DWARF5AccelTableData : public AccelTableData {
284284
const unsigned DieTag, const unsigned UnitID,
285285
const bool IsTU = false)
286286
: OffsetVal(DieOffset), ParentOffset(DefiningParentOffset),
287-
DieTag(DieTag), AbbrevID(0), IsTU(IsTU), UnitID(UnitID) {}
287+
DieTag(DieTag), AbbrevNumber(0), IsTU(IsTU), UnitID(UnitID) {}
288288

289289
#ifndef NDEBUG
290290
void print(raw_ostream &OS) const override;
@@ -326,10 +326,10 @@ class DWARF5AccelTableData : public AccelTableData {
326326
}
327327

328328
/// Sets AbbrevIndex for an Entry.
329-
void setAbbrevIndex(uint16_t AbbrevIndex) { AbbrevID = AbbrevIndex; }
329+
void setAbbrevNumber(uint16_t AbbrevNum) { AbbrevNumber = AbbrevNum; }
330330

331331
/// Returns AbbrevIndex for an Entry.
332-
uint16_t getAbbrevIndex() const { return AbbrevID; }
332+
uint16_t getAbbrevNumber() const { return AbbrevNumber; }
333333

334334
/// If `Die` has a non-null parent and the parent is not a declaration,
335335
/// return its offset.
@@ -339,7 +339,7 @@ class DWARF5AccelTableData : public AccelTableData {
339339
std::variant<const DIE *, uint64_t> OffsetVal;
340340
std::optional<uint64_t> ParentOffset;
341341
uint32_t DieTag : 16;
342-
uint32_t AbbrevID : 15;
342+
uint32_t AbbrevNumber : 15;
343343
uint32_t IsTU : 1;
344344
uint32_t UnitID;
345345
uint64_t order() const override { return getDieOffset(); }
@@ -348,7 +348,7 @@ class DWARF5AccelTableData : public AccelTableData {
348348
class DebugNamesAbbrev : public FoldingSetNode {
349349
public:
350350
uint32_t DieTag;
351-
uint32_t Index;
351+
uint32_t Number;
352352
struct AttributeEncoding {
353353
dwarf::Index Index;
354354
dwarf::Form Form;
@@ -359,9 +359,9 @@ class DebugNamesAbbrev : public FoldingSetNode {
359359
AttrVect.push_back(Attr);
360360
}
361361
/// Set abbreviation tag index.
362-
void setAbbrevTagIndex(uint32_t AbbrevIndex) { Index = AbbrevIndex; }
362+
void setNumber(uint32_t AbbrevNumber) { Number = AbbrevNumber; }
363363
/// Get abbreviation tag index.
364-
uint32_t getAbbrevTagIndex() const { return Index; }
364+
uint32_t getNumber() const { return Number; }
365365
/// Get DIE Tag.
366366
uint32_t getDieTag() const { return DieTag; }
367367
/// Used to gather unique data for the abbreviation folding set.

llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -455,15 +455,15 @@ void Dwarf5AccelTableWriter::populateAbbrevsMap() {
455455
void *InsertPos;
456456
if (DebugNamesAbbrev *Existing =
457457
AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) {
458-
Value->setAbbrevIndex(Existing->getAbbrevTagIndex());
458+
Value->setAbbrevNumber(Existing->getNumber());
459459
continue;
460460
}
461461
DebugNamesAbbrev *NewAbbrev =
462462
new (Alloc) DebugNamesAbbrev(std::move(Abbrev));
463-
NewAbbrev->setAbbrevTagIndex(AbbreviationsVector.size());
464463
AbbreviationsVector.push_back(NewAbbrev);
464+
NewAbbrev->setNumber(AbbreviationsVector.size());
465465
AbbreviationsSet.InsertNode(NewAbbrev, InsertPos);
466-
Value->setAbbrevIndex(NewAbbrev->getAbbrevTagIndex());
466+
Value->setAbbrevNumber(NewAbbrev->getNumber());
467467
}
468468
}
469469
}
@@ -515,7 +515,7 @@ void Dwarf5AccelTableWriter::emitAbbrevs() const {
515515
Asm->OutStreamer->emitLabel(AbbrevStart);
516516
for (const DebugNamesAbbrev *Abbrev : AbbreviationsVector) {
517517
Asm->OutStreamer->AddComment("Abbrev code");
518-
Asm->emitULEB128(Abbrev->getAbbrevTagIndex() + 1);
518+
Asm->emitULEB128(Abbrev->getNumber());
519519
Asm->OutStreamer->AddComment(dwarf::TagString(Abbrev->getDieTag()));
520520
Asm->emitULEB128(Abbrev->getDieTag());
521521
for (const DebugNamesAbbrev::AttributeEncoding &AttrEnc :
@@ -535,9 +535,10 @@ void Dwarf5AccelTableWriter::emitEntry(
535535
const DWARF5AccelTableData &Entry,
536536
const DenseMap<OffsetAndUnitID, MCSymbol *> &DIEOffsetToAccelEntryLabel,
537537
DenseSet<MCSymbol *> &EmittedAccelEntrySymbols) {
538-
assert(Entry.getAbbrevIndex() < AbbreviationsVector.size() &&
538+
unsigned AbbrevIndex = Entry.getAbbrevNumber() - 1;
539+
assert(AbbrevIndex < AbbreviationsVector.size() &&
539540
"Entry abbrev index is outside of abbreviations vector range.");
540-
DebugNamesAbbrev *Abbrev = AbbreviationsVector[Entry.getAbbrevIndex()];
541+
DebugNamesAbbrev *Abbrev = AbbreviationsVector[AbbrevIndex];
541542
std::optional<DWARF5AccelTable::UnitIndexAndEncoding> EntryRet =
542543
getIndexForEntry(Entry);
543544
std::optional<OffsetAndUnitID> MaybeParentOffset =
@@ -553,7 +554,7 @@ void Dwarf5AccelTableWriter::emitEntry(
553554
if (EmittedAccelEntrySymbols.insert(EntrySymbol).second)
554555
Asm->OutStreamer->emitLabel(EntrySymbol);
555556

556-
Asm->emitULEB128(Entry.getAbbrevIndex() + 1, "Abbreviation code");
557+
Asm->emitULEB128(Entry.getAbbrevNumber(), "Abbreviation code");
557558

558559
for (const DebugNamesAbbrev::AttributeEncoding &AttrEnc :
559560
Abbrev->getAttributes()) {

0 commit comments

Comments
 (0)