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 {
613613 DW_hash_function_djb = 0u
614614};
615615
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+
616635// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
617636enum GDBIndexEntryKind {
618637 GIEK_NONE,
Original file line number Diff line number Diff line change @@ -33,22 +33,12 @@ using namespace llvm;
3333
3434void AccelTableBase::computeBucketCount () {
3535 // First get the number of unique hashes.
36- std::vector <uint32_t > Uniques;
36+ SmallVector <uint32_t , 0 > Uniques;
3737 Uniques.reserve (Entries.size ());
3838 for (const auto &E : Entries)
3939 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 ());
4340
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);
5242}
5343
5444void AccelTableBase::finalize (AsmPrinter *Asm, StringRef Prefix) {
You can’t perform that action at this time.
0 commit comments