Skip to content

Commit f066377

Browse files
authored
[LLVM][DWARF] Make dwarf::getDebugNamesBucketCount return a pair. (llvm#83047)
llvm::dwarf::getDebugNamesBucketCount directly returns the bucket count, via return statement, but it also returns the hash count via a parameter. This changes the function to return them both as a std::pair, in the return statement. It also changes the name of the function to make it clear it returns both values.
1 parent e7900e6 commit f066377

File tree

2 files changed

+14
-12
lines changed

2 files changed

+14
-12
lines changed

llvm/include/llvm/BinaryFormat/Dwarf.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -615,21 +615,21 @@ enum AcceleratorTable {
615615

616616
// Uniquify the string hashes and calculate the bucket count for the
617617
// DWARF v5 Accelerator Table. NOTE: This function effectively consumes the
618-
// 'hashes' input parameter.
619-
inline uint32_t getDebugNamesBucketCount(MutableArrayRef<uint32_t> hashes,
620-
uint32_t &uniqueHashCount) {
618+
// 'Hashes' input parameter.
619+
inline std::pair<uint32_t, uint32_t>
620+
getDebugNamesBucketAndHashCount(MutableArrayRef<uint32_t> Hashes) {
621621
uint32_t BucketCount = 0;
622622

623-
sort(hashes);
624-
uniqueHashCount = llvm::unique(hashes) - hashes.begin();
625-
if (uniqueHashCount > 1024)
626-
BucketCount = uniqueHashCount / 4;
627-
else if (uniqueHashCount > 16)
628-
BucketCount = uniqueHashCount / 2;
623+
sort(Hashes);
624+
uint32_t UniqueHashCount = llvm::unique(Hashes) - Hashes.begin();
625+
if (UniqueHashCount > 1024)
626+
BucketCount = UniqueHashCount / 4;
627+
else if (UniqueHashCount > 16)
628+
BucketCount = UniqueHashCount / 2;
629629
else
630-
BucketCount = std::max<uint32_t>(uniqueHashCount, 1);
630+
BucketCount = std::max<uint32_t>(UniqueHashCount, 1);
631631

632-
return BucketCount;
632+
return {BucketCount, UniqueHashCount};
633633
}
634634

635635
// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.

llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ void AccelTableBase::computeBucketCount() {
3838
for (const auto &E : Entries)
3939
Uniques.push_back(E.second.HashValue);
4040

41-
BucketCount = llvm::dwarf::getDebugNamesBucketCount(Uniques, UniqueHashCount);
41+
auto Counts = llvm::dwarf::getDebugNamesBucketAndHashCount(Uniques);
42+
BucketCount = Counts.first;
43+
UniqueHashCount = Counts.second;
4244
}
4345

4446
void AccelTableBase::finalize(AsmPrinter *Asm, StringRef Prefix) {

0 commit comments

Comments
 (0)