File tree Expand file tree Collapse file tree 2 files changed +21
-12
lines changed
include/llvm/BinaryFormat Expand file tree Collapse file tree 2 files changed +21
-12
lines changed Original file line number Diff line number Diff line change @@ -613,6 +613,25 @@ enum AcceleratorTable {
613
613
DW_hash_function_djb = 0u
614
614
};
615
615
616
+ // Uniquify the string hashes and calculate the bucket count for the
617
+ // 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) {
621
+ uint32_t BucketCount = 0 ;
622
+
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 ;
629
+ else
630
+ BucketCount = std::max<uint32_t >(uniqueHashCount, 1 );
631
+
632
+ return BucketCount;
633
+ }
634
+
616
635
// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
617
636
enum GDBIndexEntryKind {
618
637
GIEK_NONE,
Original file line number Diff line number Diff line change @@ -33,22 +33,12 @@ using namespace llvm;
33
33
34
34
void AccelTableBase::computeBucketCount () {
35
35
// First get the number of unique hashes.
36
- std::vector <uint32_t > Uniques;
36
+ SmallVector <uint32_t , 0 > Uniques;
37
37
Uniques.reserve (Entries.size ());
38
38
for (const auto &E : Entries)
39
39
Uniques.push_back (E.second .HashValue );
40
- array_pod_sort (Uniques.begin (), Uniques.end ());
41
- std::vector<uint32_t >::iterator P =
42
- std::unique (Uniques.begin (), Uniques.end ());
43
40
44
- UniqueHashCount = std::distance (Uniques.begin (), P);
45
-
46
- if (UniqueHashCount > 1024 )
47
- BucketCount = UniqueHashCount / 4 ;
48
- else if (UniqueHashCount > 16 )
49
- BucketCount = UniqueHashCount / 2 ;
50
- else
51
- BucketCount = std::max<uint32_t >(UniqueHashCount, 1 );
41
+ BucketCount = llvm::dwarf::getDebugNamesBucketCount (Uniques, UniqueHashCount);
52
42
}
53
43
54
44
void AccelTableBase::finalize (AsmPrinter *Asm, StringRef Prefix) {
You can’t perform that action at this time.
0 commit comments