Skip to content

Commit cfbc007

Browse files
committed
[rebranch] Do not serialize unstable hashes
llvm/llvm-project#96282 changed `get_execution_seed` to be non-deterministic. Use stable hashes instead.
1 parent 0a6e587 commit cfbc007

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

include/swift/Localization/LocalizationFormat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class LocalizationWriterInfo {
6969
using hash_value_type = uint32_t;
7070
using offset_type = uint32_t;
7171

72-
hash_value_type ComputeHash(key_type_ref key) { return llvm::hash_code(key); }
72+
hash_value_type ComputeHash(key_type_ref key) { return key; }
7373

7474
std::pair<offset_type, offset_type> EmitKeyDataLength(llvm::raw_ostream &out,
7575
key_type_ref key,
@@ -113,7 +113,7 @@ class LocalizationReaderInfo {
113113
}
114114

115115
hash_value_type ComputeHash(internal_key_type key) {
116-
return llvm::hash_code(key);
116+
return key;
117117
}
118118

119119
static std::pair<offset_type, offset_type>

lib/ClangImporter/SwiftLookupTable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ namespace {
11421142
}
11431143

11441144
hash_value_type ComputeHash(key_type_ref key) {
1145-
return llvm::DenseMapInfo<SerializedSwiftName>::getHashValue(key);
1145+
return static_cast<unsigned>(key.Kind) + llvm::djbHash(key.Name);
11461146
}
11471147

11481148
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
@@ -1421,7 +1421,7 @@ namespace {
14211421
}
14221422

14231423
hash_value_type ComputeHash(internal_key_type key) {
1424-
return llvm::DenseMapInfo<SerializedSwiftName>::getHashValue(key);
1424+
return static_cast<unsigned>(key.Kind) + llvm::djbHash(key.Name);
14251425
}
14261426

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

lib/ClangImporter/SwiftLookupTable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MAJOR = 1;
283283
/// Lookup table minor version number.
284284
///
285285
/// When the format changes IN ANY WAY, this number should be incremented.
286-
const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MINOR = 19; // 64-bit clang serialization IDs
286+
const uint16_t SWIFT_LOOKUP_TABLE_VERSION_MINOR = 20; // hash functions
287287

288288

289289
/// A lookup table that maps Swift names to the set of Clang

lib/Serialization/ModuleFileCoreTableInfo.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ class ModuleFileSharedCore::DeclMembersTableInfo {
318318
}
319319

320320
hash_value_type ComputeHash(internal_key_type key) {
321-
return llvm::hash_value(key);
321+
return key;
322322
}
323323

324324
static bool EqualKey(internal_key_type lhs, internal_key_type rhs) {
@@ -557,7 +557,7 @@ class ModuleFileSharedCore::DeclFingerprintsTableInfo {
557557
internal_key_type GetInternalKey(external_key_type ID) { return ID; }
558558

559559
hash_value_type ComputeHash(internal_key_type key) {
560-
return llvm::hash_value(key);
560+
return key;
561561
}
562562

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

lib/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ const uint16_t SWIFTMODULE_VERSION_MAJOR = 0;
5858
/// describe what change you made. The content of this comment isn't important;
5959
/// it just ensures a conflict if two people change the module format.
6060
/// Don't worry about adhering to the 80-column limit for this line.
61-
const uint16_t SWIFTMODULE_VERSION_MINOR = 881; // Changes to LifetimeDependence
61+
const uint16_t SWIFTMODULE_VERSION_MINOR = 882; // hash functions
6262

6363
/// A standard hash seed used for all string hashes in a serialized module.
6464
///

lib/Serialization/Serialization.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ namespace {
414414
using offset_type = unsigned;
415415

416416
hash_value_type ComputeHash(key_type_ref key) {
417-
return llvm::hash_value(static_cast<uint32_t>(key));
417+
return static_cast<uint32_t>(key);
418418
}
419419

420420
std::pair<unsigned, unsigned> EmitKeyDataLength(raw_ostream &out,
@@ -459,7 +459,7 @@ namespace {
459459
using offset_type = unsigned;
460460

461461
hash_value_type ComputeHash(key_type_ref key) {
462-
return llvm::hash_value(static_cast<uint32_t>(key));
462+
return static_cast<uint32_t>(key);
463463
}
464464

465465
std::pair<unsigned, unsigned>

0 commit comments

Comments
 (0)