[llvm] r323341 - [NFC] Make magic number for DJB hash function customizable.

Jonas Devlieghere via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 24 08:53:14 PST 2018


Author: jdevlieghere
Date: Wed Jan 24 08:53:14 2018
New Revision: 323341

URL: http://llvm.org/viewvc/llvm-project?rev=323341&view=rev
Log:
[NFC] Make magic number for DJB hash function customizable.

This allows us to specify the magic number for the DJB hash function.
This feature is needed by dsymutil to emit Apple types accelerator
table.

Modified:
    llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
    llvm/trunk/lib/BinaryFormat/Dwarf.cpp

Modified: llvm/trunk/include/llvm/BinaryFormat/Dwarf.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/BinaryFormat/Dwarf.h?rev=323341&r1=323340&r2=323341&view=diff
==============================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Dwarf.h (original)
+++ llvm/trunk/include/llvm/BinaryFormat/Dwarf.h Wed Jan 24 08:53:14 2018
@@ -526,7 +526,7 @@ private:
 enum DwarfFormat : uint8_t { DWARF32, DWARF64 };
 
 /// The Bernstein hash function used by the accelerator tables.
-uint32_t djbHash(StringRef Buffer);
+uint32_t djbHash(StringRef Buffer, uint32_t H = 5381);
 
 } // End of namespace dwarf
 

Modified: llvm/trunk/lib/BinaryFormat/Dwarf.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/BinaryFormat/Dwarf.cpp?rev=323341&r1=323340&r2=323341&view=diff
==============================================================================
--- llvm/trunk/lib/BinaryFormat/Dwarf.cpp (original)
+++ llvm/trunk/lib/BinaryFormat/Dwarf.cpp Wed Jan 24 08:53:14 2018
@@ -587,8 +587,7 @@ bool llvm::dwarf::isValidFormForVersion(
   return ExtensionsOk;
 }
 
-uint32_t llvm::dwarf::djbHash(StringRef Buffer) {
-  uint32_t H = 5381;
+uint32_t llvm::dwarf::djbHash(StringRef Buffer, uint32_t H) {
   for (char C : Buffer.bytes())
     H = ((H << 5) + H) + C;
   return H;




More information about the llvm-commits mailing list