Skip to content

Commit 6496175

Browse files
committed
[Serialization] Omit local discrimiator from LocalDeclTableInfo
Local discriminators are emitted as a part of decl.
1 parent 9fc0985 commit 6496175

File tree

3 files changed

+10
-18
lines changed

3 files changed

+10
-18
lines changed

include/swift/Serialization/ModuleFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const uint16_t VERSION_MAJOR = 0;
5555
/// describe what change you made. The content of this comment isn't important;
5656
/// it just ensures a conflict if two people change the module format.
5757
/// Don't worry about adhering to the 80-column limit for this line.
58-
const uint16_t VERSION_MINOR = 418; // Last change: add begin_access [builtin].
58+
const uint16_t VERSION_MINOR = 419; // Last change: Remove discriminator from LocalDeclTableInfo.
5959

6060
using DeclIDField = BCFixed<31>;
6161

lib/Serialization/ModuleFile.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ class ModuleFile::LocalDeclTableInfo {
429429
public:
430430
using internal_key_type = StringRef;
431431
using external_key_type = internal_key_type;
432-
using data_type = std::pair<DeclID, unsigned>; // ID, local discriminator
432+
using data_type = DeclID;
433433
using hash_value_type = uint32_t;
434434
using offset_type = unsigned;
435435

@@ -447,7 +447,7 @@ class ModuleFile::LocalDeclTableInfo {
447447

448448
static std::pair<unsigned, unsigned> ReadKeyDataLength(const uint8_t *&data) {
449449
unsigned keyLength = endian::readNext<uint16_t, little, unaligned>(data);
450-
return { keyLength, sizeof(uint32_t) + sizeof(unsigned) };
450+
return { keyLength, sizeof(uint32_t) };
451451
}
452452

453453
static internal_key_type ReadKey(const uint8_t *data, unsigned length) {
@@ -456,9 +456,7 @@ class ModuleFile::LocalDeclTableInfo {
456456

457457
static data_type ReadData(internal_key_type key, const uint8_t *data,
458458
unsigned length) {
459-
auto declID = endian::readNext<uint32_t, little, unaligned>(data);
460-
auto discriminator = endian::readNext<unsigned, little, unaligned>(data);
461-
return { declID, discriminator };
459+
return endian::readNext<uint32_t, little, unaligned>(data);
462460
}
463461
};
464462

@@ -1516,7 +1514,7 @@ TypeDecl *ModuleFile::lookupLocalType(StringRef MangledName) {
15161514
if (iter == LocalTypeDecls->end())
15171515
return nullptr;
15181516

1519-
return cast<TypeDecl>(getDecl((*iter).first));
1517+
return cast<TypeDecl>(getDecl(*iter));
15201518
}
15211519

15221520
TypeDecl *ModuleFile::lookupNestedType(Identifier name,
@@ -2021,11 +2019,8 @@ ModuleFile::getLocalTypeDecls(SmallVectorImpl<TypeDecl *> &results) {
20212019
if (!LocalTypeDecls)
20222020
return;
20232021

2024-
for (auto entry : LocalTypeDecls->data()) {
2025-
auto DeclID = entry.first;
2022+
for (auto DeclID : LocalTypeDecls->data()) {
20262023
auto TD = cast<TypeDecl>(getDecl(DeclID));
2027-
assert(entry.second == TD->getLocalDiscriminator());
2028-
// TD->setLocalDiscriminator(entry.second);
20292024
results.push_back(TD);
20302025
}
20312026
}

lib/Serialization/Serialization.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ namespace {
228228
public:
229229
using key_type = std::string;
230230
using key_type_ref = StringRef;
231-
using data_type = std::pair<DeclID, unsigned>; // ID, local discriminator
231+
using data_type = DeclID;
232232
using data_type_ref = const data_type &;
233233
using hash_value_type = uint32_t;
234234
using offset_type = unsigned;
@@ -242,7 +242,7 @@ namespace {
242242
key_type_ref key,
243243
data_type_ref data) {
244244
uint32_t keyLength = key.size();
245-
uint32_t dataLength = sizeof(uint32_t) + sizeof(unsigned);
245+
uint32_t dataLength = sizeof(uint32_t);
246246
endian::Writer<little> writer(out);
247247
writer.write<uint16_t>(keyLength);
248248
return { keyLength, dataLength };
@@ -256,8 +256,7 @@ namespace {
256256
unsigned len) {
257257
static_assert(declIDFitsIn32Bits(), "DeclID too large");
258258
endian::Writer<little> writer(out);
259-
writer.write<uint32_t>(data.first);
260-
writer.write<unsigned>(data.second);
259+
writer.write<uint32_t>(data);
261260
}
262261
};
263262

@@ -4909,9 +4908,7 @@ void Serializer::writeAST(ModuleOrSourceFile DC,
49094908
Mangle::ASTMangler Mangler;
49104909
std::string MangledName = Mangler.mangleDeclAsUSR(TD, /*USRPrefix*/"");
49114910
assert(!MangledName.empty() && "Mangled type came back empty!");
4912-
localTypeGenerator.insert(MangledName, {
4913-
addDeclRef(TD), TD->getLocalDiscriminator()
4914-
});
4911+
localTypeGenerator.insert(MangledName, addDeclRef(TD));
49154912

49164913
if (auto IDC = dyn_cast<IterableDeclContext>(TD)) {
49174914
collectInterestingNestedDeclarations(*this, IDC->getMembers(),

0 commit comments

Comments
 (0)