Skip to content

Commit b7eb3bf

Browse files
authored
Merge pull request #14862 from compnerd/hash
upstream-update: adjust for SVN r326091
2 parents 631ba28 + a0c6a70 commit b7eb3bf

File tree

6 files changed

+25
-19
lines changed

6 files changed

+25
-19
lines changed

lib/ClangImporter/SwiftLookupTable.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include "llvm/Bitcode/BitstreamReader.h"
3434
#include "llvm/Bitcode/BitstreamWriter.h"
3535
#include "llvm/Bitcode/RecordLayout.h"
36+
#include "llvm/Support/DJB.h"
3637
#include "llvm/Support/OnDiskHashTable.h"
3738

3839
using namespace swift;
@@ -1054,7 +1055,7 @@ namespace {
10541055
}
10551056

10561057
hash_value_type ComputeHash(key_type_ref key) {
1057-
return static_cast<unsigned>(key.first) + llvm::HashString(key.second);
1058+
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second);
10581059
}
10591060

10601061
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
@@ -1297,7 +1298,7 @@ namespace {
12971298
}
12981299

12991300
hash_value_type ComputeHash(internal_key_type key) {
1300-
return static_cast<unsigned>(key.first) + llvm::HashString(key.second);
1301+
return static_cast<unsigned>(key.first) + llvm::djbHash(key.second);
13011302
}
13021303

13031304
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {

lib/Sema/TypeCheckDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "llvm/ADT/StringExtras.h"
4949
#include "llvm/ADT/Twine.h"
5050
#include "llvm/Support/Compiler.h"
51+
#include "llvm/Support/DJB.h"
5152

5253
using namespace swift;
5354

@@ -168,7 +169,7 @@ class DenseMapInfo<RawValueKey> {
168169
return DenseMapInfo<uint64_t>::getHashValue(k.intValue.v0) &
169170
DenseMapInfo<uint64_t>::getHashValue(k.intValue.v1);
170171
case RawValueKey::Kind::String:
171-
return llvm::HashString(k.stringValue);
172+
return llvm::djbHash(k.stringValue);
172173
case RawValueKey::Kind::Empty:
173174
case RawValueKey::Kind::Tombstone:
174175
return 0;

lib/Serialization/DeserializeSIL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "llvm/ADT/Statistic.h"
3030
#include "llvm/ADT/StringExtras.h"
3131
#include "llvm/Support/Debug.h"
32+
#include "llvm/Support/DJB.h"
3233
#include "llvm/Support/OnDiskHashTable.h"
3334

3435
#include <type_traits>
@@ -102,7 +103,7 @@ class SILDeserializer::FuncTableInfo {
102103
external_key_type GetExternalKey(internal_key_type ID) { return ID; }
103104

104105
hash_value_type ComputeHash(internal_key_type key) {
105-
return llvm::HashString(key);
106+
return llvm::djbHash(key);
106107
}
107108

108109
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {

lib/Serialization/ModuleFile.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "swift/Serialization/BCReadingExtras.h"
2828
#include "swift/Serialization/SerializedModuleLoader.h"
2929
#include "llvm/ADT/StringExtras.h"
30+
#include "llvm/Support/DJB.h"
3031
#include "llvm/Support/MemoryBuffer.h"
3132
#include "llvm/Support/OnDiskHashTable.h"
3233

@@ -317,7 +318,7 @@ class ModuleFile::DeclTableInfo {
317318

318319
hash_value_type ComputeHash(internal_key_type key) {
319320
if (key.first == DeclBaseName::Kind::Normal) {
320-
return llvm::HashString(key.second);
321+
return llvm::djbHash(key.second);
321322
} else {
322323
return (hash_value_type)key.first;
323324
}
@@ -379,7 +380,7 @@ class ModuleFile::ExtensionTableInfo {
379380
}
380381

381382
hash_value_type ComputeHash(internal_key_type key) {
382-
return llvm::HashString(key);
383+
return llvm::djbHash(key);
383384
}
384385

385386
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
@@ -438,7 +439,7 @@ class ModuleFile::LocalDeclTableInfo {
438439
}
439440

440441
hash_value_type ComputeHash(internal_key_type key) {
441-
return llvm::HashString(key);
442+
return llvm::djbHash(key);
442443
}
443444

444445
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
@@ -475,7 +476,7 @@ class ModuleFile::NestedTypeDeclsTableInfo {
475476
}
476477

477478
hash_value_type ComputeHash(internal_key_type key) {
478-
return llvm::HashString(key);
479+
return llvm::djbHash(key);
479480
}
480481

481482
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
@@ -530,7 +531,7 @@ class ModuleFile::DeclMemberNamesTableInfo {
530531

531532
hash_value_type ComputeHash(internal_key_type key) {
532533
if (key.first == DeclBaseName::Kind::Normal) {
533-
return llvm::HashString(key.second);
534+
return llvm::djbHash(key.second);
534535
} else {
535536
return (hash_value_type)key.first;
536537
}
@@ -703,7 +704,7 @@ class ModuleFile::ObjCMethodTableInfo {
703704
}
704705

705706
hash_value_type ComputeHash(internal_key_type key) {
706-
return llvm::HashString(key);
707+
return llvm::djbHash(key);
707708
}
708709

709710
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
@@ -890,7 +891,7 @@ class ModuleFile::DeclCommentTableInfo {
890891

891892
hash_value_type ComputeHash(internal_key_type key) {
892893
assert(!key.empty());
893-
return llvm::HashString(key);
894+
return llvm::djbHash(key);
894895
}
895896

896897
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {

lib/Serialization/Serialization.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "llvm/Config/config.h"
4949
#include "llvm/Support/Allocator.h"
5050
#include "llvm/Support/Compiler.h"
51+
#include "llvm/Support/DJB.h"
5152
#include "llvm/Support/EndianStream.h"
5253
#include "llvm/Support/FileSystem.h"
5354
#include "llvm/Support/MemoryBuffer.h"
@@ -100,7 +101,7 @@ namespace {
100101
switch (key.getKind()) {
101102
case DeclBaseName::Kind::Normal:
102103
assert(!key.empty());
103-
return llvm::HashString(key.getIdentifier().str());
104+
return llvm::djbHash(key.getIdentifier().str());
104105
case DeclBaseName::Kind::Subscript:
105106
return static_cast<uint8_t>(DeclNameKind::Subscript);
106107
case DeclBaseName::Kind::Destructor:
@@ -167,7 +168,7 @@ namespace {
167168

168169
hash_value_type ComputeHash(key_type_ref key) {
169170
assert(!key.empty());
170-
return llvm::HashString(key.str());
171+
return llvm::djbHash(key.str());
171172
}
172173

173174
int32_t getNameDataForBase(const NominalTypeDecl *nominal,
@@ -229,7 +230,7 @@ namespace {
229230

230231
hash_value_type ComputeHash(key_type_ref key) {
231232
assert(!key.empty());
232-
return llvm::HashString(key);
233+
return llvm::djbHash(key);
233234
}
234235

235236
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
@@ -269,7 +270,7 @@ namespace {
269270

270271
hash_value_type ComputeHash(key_type_ref key) {
271272
assert(!key.empty());
272-
return llvm::HashString(key.str());
273+
return llvm::djbHash(key.str());
273274
}
274275

275276
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
@@ -312,7 +313,7 @@ namespace {
312313
switch (key.getKind()) {
313314
case DeclBaseName::Kind::Normal:
314315
assert(!key.empty());
315-
return llvm::HashString(key.getIdentifier().str());
316+
return llvm::djbHash(key.getIdentifier().str());
316317
case DeclBaseName::Kind::Subscript:
317318
return static_cast<uint8_t>(DeclNameKind::Subscript);
318319
case DeclBaseName::Kind::Destructor:
@@ -4265,7 +4266,7 @@ class DeclCommentTableInfo {
42654266

42664267
hash_value_type ComputeHash(key_type_ref key) {
42674268
assert(!key.empty());
4268-
return llvm::HashString(key);
4269+
return llvm::djbHash(key);
42694270
}
42704271

42714272
std::pair<unsigned, unsigned>
@@ -4636,7 +4637,7 @@ namespace {
46364637

46374638
hash_value_type ComputeHash(key_type_ref key) {
46384639
llvm::SmallString<32> scratch;
4639-
return llvm::HashString(key.getString(scratch));
4640+
return llvm::djbHash(key.getString(scratch));
46404641
}
46414642

46424643
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,

lib/Serialization/SerializeSIL.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "llvm/ADT/StringExtras.h"
3131
#include "llvm/Support/CommandLine.h"
3232
#include "llvm/Support/Debug.h"
33+
#include "llvm/Support/DJB.h"
3334
#include "llvm/Support/EndianStream.h"
3435
#include "llvm/Support/OnDiskHashTable.h"
3536

@@ -110,7 +111,7 @@ namespace {
110111

111112
hash_value_type ComputeHash(key_type_ref key) {
112113
assert(!key.empty());
113-
return llvm::HashString(key.str());
114+
return llvm::djbHash(key.str());
114115
}
115116

116117
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,

0 commit comments

Comments
 (0)