[llvm] [LLVM][DWARF] Make dwarf::getDebugNamesBucketCount return a pair. (PR #83047)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 26 11:03:18 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-binary-utilities
Author: None (cmtice)
<details>
<summary>Changes</summary>
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.
---
Full diff: https://github.com/llvm/llvm-project/pull/83047.diff
2 Files Affected:
- (modified) llvm/include/llvm/BinaryFormat/Dwarf.h (+8-7)
- (modified) llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp (+3-1)
``````````diff
diff --git a/llvm/include/llvm/BinaryFormat/Dwarf.h b/llvm/include/llvm/BinaryFormat/Dwarf.h
index 44c0030251b37e..e2d79785162e37 100644
--- a/llvm/include/llvm/BinaryFormat/Dwarf.h
+++ b/llvm/include/llvm/BinaryFormat/Dwarf.h
@@ -616,20 +616,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) {
- uint32_t BucketCount = 0;
+inline std::pair<uint32_t, uint32_t> getDebugNamesBucketAndHashCount(
+ MutableArrayRef<uint32_t> hashes) {
+ uint32_t uniqueHashCount = 0;
+ uint32_t bucketCount = 0;
sort(hashes);
uniqueHashCount = llvm::unique(hashes) - hashes.begin();
if (uniqueHashCount > 1024)
- BucketCount = uniqueHashCount / 4;
+ bucketCount = uniqueHashCount / 4;
else if (uniqueHashCount > 16)
- BucketCount = uniqueHashCount / 2;
+ 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..94e9d5e9cb77ce 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) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/83047
More information about the llvm-commits
mailing list