[llvm] f066377 - [LLVM][DWARF] Make dwarf::getDebugNamesBucketCount return a pair. (#83047)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 21:54:14 PST 2024
Author: cmtice
Date: 2024-02-26T21:54:10-08:00
New Revision: f0663772463335bed253491fa380e1a9c2d78484
URL: https://github.com/llvm/llvm-project/commit/f0663772463335bed253491fa380e1a9c2d78484
DIFF: https://github.com/llvm/llvm-project/commit/f0663772463335bed253491fa380e1a9c2d78484.diff
LOG: [LLVM][DWARF] Make dwarf::getDebugNamesBucketCount return a pair. (#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.
Added:
Modified:
llvm/include/llvm/BinaryFormat/Dwarf.h
llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
Removed:
################################################################################
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<uint32_t> hashes,
- uint32_t &uniqueHashCount) {
+// 'Hashes' input parameter.
+inline std::pair<uint32_t, uint32_t>
+getDebugNamesBucketAndHashCount(MutableArrayRef<uint32_t> 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<uint32_t>(uniqueHashCount, 1);
+ BucketCount = std::max<uint32_t>(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) {
More information about the llvm-commits
mailing list