aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
diff options
context:
space:
mode:
authorFangrui Song <i@maskray.me>2024-04-09 11:02:39 -0700
committerGitHub <noreply@github.com>2024-04-09 11:02:39 -0700
commitd3016aa889ac12fd8a047d68fed2ddaca107b990 (patch)
tree241147671e93c4d0d75e506120284c11f10a0aac /llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
parenta454d92c5ac906d391b683661ac3d9a362ab0107 (diff)
downloadllvm-d3016aa889ac12fd8a047d68fed2ddaca107b990.zip
llvm-d3016aa889ac12fd8a047d68fed2ddaca107b990.tar.gz
llvm-d3016aa889ac12fd8a047d68fed2ddaca107b990.tar.bz2
[DWARF] Refactor .debug_names bucket count computation (#88087)
`getDebugNamesBucketAndHashCount` lures users to provide an array to compute the bucket count using an O(n log n) sort. This is inefficient as hash table based uniquifying is faster. The performance issue matters less for Clang as the number of names is relatively small. For `ld.lld --debug-names`, I plan to compute the unique hash count as a side product of parallel entry pool computation, and I just need a function to suggest a bucket count.
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
index 2e8e7d0..5b679fd 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp
@@ -32,14 +32,13 @@
using namespace llvm;
void AccelTableBase::computeBucketCount() {
- // First get the number of unique hashes.
SmallVector<uint32_t, 0> Uniques;
Uniques.reserve(Entries.size());
for (const auto &E : Entries)
Uniques.push_back(E.second.HashValue);
-
- std::tie(BucketCount, UniqueHashCount) =
- llvm::dwarf::getDebugNamesBucketAndHashCount(Uniques);
+ llvm::sort(Uniques);
+ UniqueHashCount = llvm::unique(Uniques) - Uniques.begin();
+ BucketCount = dwarf::getDebugNamesBucketCount(UniqueHashCount);
}
void AccelTableBase::finalize(AsmPrinter *Asm, StringRef Prefix) {