diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h index 44c0030251b37e..a53e79bf6e39c1 100644 --- a/llvm/include/llvm/BinaryFormat/Dwarf.h +++ b/llvm/include/llvm/BinaryFormat/Dwarf.h @@ -615,21 +615,21 @@ enum AcceleratorTable { // Uniquify the string hashes and calculate the bucket count for the // DWARF v5 Accelerator Table. NOTE: This function effectively consumes the -// 'hashes' input parameter. -inline uint32_t getDebugNamesBucketCount(MutableArrayRef hashes, - uint32_t &uniqueHashCount) { +// 'Hashes' input parameter. +inline std::pair +getDebugNamesBucketAndHashCount(MutableArrayRef Hashes) { uint32_t BucketCount = 0; - sort(hashes); - uniqueHashCount = llvm::unique(hashes) - hashes.begin(); - if (uniqueHashCount > 1024) - BucketCount = uniqueHashCount / 4; - else if (uniqueHashCount > 16) - BucketCount = uniqueHashCount / 2; + sort(Hashes); + uint32_t UniqueHashCount = llvm::unique(Hashes) - Hashes.begin(); + if (UniqueHashCount > 1024) + BucketCount = UniqueHashCount / 4; + else if (UniqueHashCount > 16) + BucketCount = UniqueHashCount / 2; else - BucketCount = std::max(uniqueHashCount, 1); + BucketCount = std::max(UniqueHashCount, 1); - return BucketCount; + return {BucketCount, UniqueHashCount}; } // Constants for the GNU pubnames/pubtypes extensions supporting gdb index. diff --git a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp index 23fc9b2e0410e0..9e1727a0b8d138 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp @@ -38,7 +38,9 @@ void AccelTableBase::computeBucketCount() { for (const auto &E : Entries) Uniques.push_back(E.second.HashValue); - BucketCount = llvm::dwarf::getDebugNamesBucketCount(Uniques, UniqueHashCount); + auto Counts = llvm::dwarf::getDebugNamesBucketAndHashCount(Uniques); + BucketCount = Counts.first; + UniqueHashCount = Counts.second; } void AccelTableBase::finalize(AsmPrinter *Asm, StringRef Prefix) {