Skip to content

Commit acdf40c

Browse files
[AsmPrinter][Dwarf5][nfc] Remove template from AccelTable class
This template is no longer used.
1 parent 80aeb62 commit acdf40c

File tree

1 file changed

+25
-37
lines changed

1 file changed

+25
-37
lines changed

llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp

Lines changed: 25 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,7 @@ class AppleAccelTableWriter : public AccelTableWriter {
182182
/// Class responsible for emitting a DWARF v5 Accelerator Table. The only
183183
/// public function is emit(), which performs the actual emission.
184184
///
185-
/// The class is templated in its data type. This allows us to emit both dyamic
186-
/// and static data entries. A callback abstract the logic to provide a CU
187-
/// index for a given entry, which is different per data type, but identical
188-
/// for every entry in the same table.
189-
template <typename DataT>
185+
/// A callback abstracts the logic to provide a CU index for a given entry.
190186
class Dwarf5AccelTableWriter : public AccelTableWriter {
191187
struct Header {
192188
uint16_t Version = 5;
@@ -216,7 +212,7 @@ class Dwarf5AccelTableWriter : public AccelTableWriter {
216212
ArrayRef<std::variant<MCSymbol *, uint64_t>> CompUnits;
217213
ArrayRef<std::variant<MCSymbol *, uint64_t>> TypeUnits;
218214
llvm::function_ref<std::optional<DWARF5AccelTable::UnitIndexAndEncoding>(
219-
const DataT &)>
215+
const DWARF5AccelTableData &)>
220216
getIndexForEntry;
221217
MCSymbol *ContributionEnd = nullptr;
222218
MCSymbol *AbbrevStart = Asm->createTempSymbol("names_abbrev_start");
@@ -232,16 +228,16 @@ class Dwarf5AccelTableWriter : public AccelTableWriter {
232228
void emitBuckets() const;
233229
void emitStringOffsets() const;
234230
void emitAbbrevs() const;
235-
void emitEntry(const DataT &Entry) const;
231+
void emitEntry(const DWARF5AccelTableData &Entry) const;
236232
void emitData() const;
237233

238234
public:
239235
Dwarf5AccelTableWriter(
240236
AsmPrinter *Asm, const AccelTableBase &Contents,
241237
ArrayRef<std::variant<MCSymbol *, uint64_t>> CompUnits,
242238
ArrayRef<std::variant<MCSymbol *, uint64_t>> TypeUnits,
243-
llvm::function_ref<
244-
std::optional<DWARF5AccelTable::UnitIndexAndEncoding>(const DataT &)>
239+
llvm::function_ref<std::optional<DWARF5AccelTable::UnitIndexAndEncoding>(
240+
const DWARF5AccelTableData &)>
245241
getIndexForEntry,
246242
bool IsSplitDwarf);
247243

@@ -370,8 +366,7 @@ DWARF5AccelTableData::DWARF5AccelTableData(const DIE &Die,
370366
const bool IsTU)
371367
: OffsetVal(&Die), DieTag(Die.getTag()), UnitID(UnitID), IsTU(IsTU) {}
372368

373-
template <typename DataT>
374-
void Dwarf5AccelTableWriter<DataT>::Header::emit(Dwarf5AccelTableWriter &Ctx) {
369+
void Dwarf5AccelTableWriter::Header::emit(Dwarf5AccelTableWriter &Ctx) {
375370
assert(CompUnitCount > 0 && "Index must have at least one CU.");
376371

377372
AsmPrinter *Asm = Ctx.Asm;
@@ -417,14 +412,14 @@ static uint32_t constructAbbreviationTag(
417412
AbbrvTag |= Tag << LowerBitSize;
418413
return AbbrvTag;
419414
}
420-
template <typename DataT>
421-
void Dwarf5AccelTableWriter<DataT>::populateAbbrevsMap() {
415+
void Dwarf5AccelTableWriter::populateAbbrevsMap() {
422416
for (auto &Bucket : Contents.getBuckets()) {
423417
for (auto *Hash : Bucket) {
424418
for (auto *Value : Hash->Values) {
425419
std::optional<DWARF5AccelTable::UnitIndexAndEncoding> EntryRet =
426-
getIndexForEntry(*static_cast<const DataT *>(Value));
427-
unsigned Tag = static_cast<const DataT *>(Value)->getDieTag();
420+
getIndexForEntry(*static_cast<const DWARF5AccelTableData *>(Value));
421+
unsigned Tag =
422+
static_cast<const DWARF5AccelTableData *>(Value)->getDieTag();
428423
uint32_t AbbrvTag = constructAbbreviationTag(Tag, EntryRet);
429424
if (Abbreviations.count(AbbrvTag) == 0) {
430425
SmallVector<DWARF5AccelTableData::AttributeEncoding, 2> UA;
@@ -438,8 +433,7 @@ void Dwarf5AccelTableWriter<DataT>::populateAbbrevsMap() {
438433
}
439434
}
440435

441-
template <typename DataT>
442-
void Dwarf5AccelTableWriter<DataT>::emitCUList() const {
436+
void Dwarf5AccelTableWriter::emitCUList() const {
443437
for (const auto &CU : enumerate(CompUnits)) {
444438
Asm->OutStreamer->AddComment("Compilation unit " + Twine(CU.index()));
445439
if (std::holds_alternative<MCSymbol *>(CU.value()))
@@ -449,8 +443,7 @@ void Dwarf5AccelTableWriter<DataT>::emitCUList() const {
449443
}
450444
}
451445

452-
template <typename DataT>
453-
void Dwarf5AccelTableWriter<DataT>::emitTUList() const {
446+
void Dwarf5AccelTableWriter::emitTUList() const {
454447
for (const auto &TU : enumerate(TypeUnits)) {
455448
Asm->OutStreamer->AddComment("Type unit " + Twine(TU.index()));
456449
if (std::holds_alternative<MCSymbol *>(TU.value()))
@@ -462,8 +455,7 @@ void Dwarf5AccelTableWriter<DataT>::emitTUList() const {
462455
}
463456
}
464457

465-
template <typename DataT>
466-
void Dwarf5AccelTableWriter<DataT>::emitBuckets() const {
458+
void Dwarf5AccelTableWriter::emitBuckets() const {
467459
uint32_t Index = 1;
468460
for (const auto &Bucket : enumerate(Contents.getBuckets())) {
469461
Asm->OutStreamer->AddComment("Bucket " + Twine(Bucket.index()));
@@ -472,8 +464,7 @@ void Dwarf5AccelTableWriter<DataT>::emitBuckets() const {
472464
}
473465
}
474466

475-
template <typename DataT>
476-
void Dwarf5AccelTableWriter<DataT>::emitStringOffsets() const {
467+
void Dwarf5AccelTableWriter::emitStringOffsets() const {
477468
for (const auto &Bucket : enumerate(Contents.getBuckets())) {
478469
for (auto *Hash : Bucket.value()) {
479470
DwarfStringPoolEntryRef String = Hash->Name;
@@ -484,8 +475,7 @@ void Dwarf5AccelTableWriter<DataT>::emitStringOffsets() const {
484475
}
485476
}
486477

487-
template <typename DataT>
488-
void Dwarf5AccelTableWriter<DataT>::emitAbbrevs() const {
478+
void Dwarf5AccelTableWriter::emitAbbrevs() const {
489479
Asm->OutStreamer->emitLabel(AbbrevStart);
490480
for (const auto &Abbrev : Abbreviations) {
491481
Asm->OutStreamer->AddComment("Abbrev code");
@@ -506,8 +496,8 @@ void Dwarf5AccelTableWriter<DataT>::emitAbbrevs() const {
506496
Asm->OutStreamer->emitLabel(AbbrevEnd);
507497
}
508498

509-
template <typename DataT>
510-
void Dwarf5AccelTableWriter<DataT>::emitEntry(const DataT &Entry) const {
499+
void Dwarf5AccelTableWriter::emitEntry(
500+
const DWARF5AccelTableData &Entry) const {
511501
std::optional<DWARF5AccelTable::UnitIndexAndEncoding> EntryRet =
512502
getIndexForEntry(Entry);
513503
uint32_t AbbrvTag = constructAbbreviationTag(Entry.getDieTag(), EntryRet);
@@ -537,27 +527,26 @@ void Dwarf5AccelTableWriter<DataT>::emitEntry(const DataT &Entry) const {
537527
}
538528
}
539529

540-
template <typename DataT> void Dwarf5AccelTableWriter<DataT>::emitData() const {
530+
void Dwarf5AccelTableWriter::emitData() const {
541531
Asm->OutStreamer->emitLabel(EntryPool);
542532
for (auto &Bucket : Contents.getBuckets()) {
543533
for (auto *Hash : Bucket) {
544534
// Remember to emit the label for our offset.
545535
Asm->OutStreamer->emitLabel(Hash->Sym);
546536
for (const auto *Value : Hash->Values)
547-
emitEntry(*static_cast<const DataT *>(Value));
537+
emitEntry(*static_cast<const DWARF5AccelTableData *>(Value));
548538
Asm->OutStreamer->AddComment("End of list: " + Hash->Name.getString());
549539
Asm->emitInt8(0);
550540
}
551541
}
552542
}
553543

554-
template <typename DataT>
555-
Dwarf5AccelTableWriter<DataT>::Dwarf5AccelTableWriter(
544+
Dwarf5AccelTableWriter::Dwarf5AccelTableWriter(
556545
AsmPrinter *Asm, const AccelTableBase &Contents,
557546
ArrayRef<std::variant<MCSymbol *, uint64_t>> CompUnits,
558547
ArrayRef<std::variant<MCSymbol *, uint64_t>> TypeUnits,
559-
llvm::function_ref<
560-
std::optional<DWARF5AccelTable::UnitIndexAndEncoding>(const DataT &)>
548+
llvm::function_ref<std::optional<DWARF5AccelTable::UnitIndexAndEncoding>(
549+
const DWARF5AccelTableData &)>
561550
getIndexForEntry,
562551
bool IsSplitDwarf)
563552
: AccelTableWriter(Asm, Contents, false),
@@ -570,7 +559,7 @@ Dwarf5AccelTableWriter<DataT>::Dwarf5AccelTableWriter(
570559
populateAbbrevsMap();
571560
}
572561

573-
template <typename DataT> void Dwarf5AccelTableWriter<DataT>::emit() {
562+
void Dwarf5AccelTableWriter::emit() {
574563
Header.emit(*this);
575564
emitCUList();
576565
emitTUList();
@@ -635,7 +624,7 @@ void llvm::emitDWARF5AccelTable(
635624
DIEInteger::BestForm(/*IsSigned*/ false, CompUnits.size() - 1);
636625
dwarf::Form TUIndexForm =
637626
DIEInteger::BestForm(/*IsSigned*/ false, TypeUnits.size() - 1);
638-
Dwarf5AccelTableWriter<DWARF5AccelTableData>(
627+
Dwarf5AccelTableWriter(
639628
Asm, Contents, CompUnits, TypeUnits,
640629
[&](const DWARF5AccelTableData &Entry)
641630
-> std::optional<DWARF5AccelTable::UnitIndexAndEncoding> {
@@ -667,8 +656,7 @@ void llvm::emitDWARF5AccelTable(
667656
getIndexForEntry) {
668657
std::vector<std::variant<MCSymbol *, uint64_t>> TypeUnits;
669658
Contents.finalize(Asm, "names");
670-
Dwarf5AccelTableWriter<DWARF5AccelTableData>(Asm, Contents, CUs, TypeUnits,
671-
getIndexForEntry, false)
659+
Dwarf5AccelTableWriter(Asm, Contents, CUs, TypeUnits, getIndexForEntry, false)
672660
.emit();
673661
}
674662

0 commit comments

Comments
 (0)