Skip to content

Commit 1a4ee5e

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

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 = 412; // Last change: add begin_access [builtin].
58+
const uint16_t VERSION_MINOR = 413; // 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

@@ -1527,7 +1525,7 @@ TypeDecl *ModuleFile::lookupLocalType(StringRef MangledName) {
15271525
if (iter == LocalTypeDecls->end())
15281526
return nullptr;
15291527

1530-
return cast<TypeDecl>(getDecl((*iter).first));
1528+
return cast<TypeDecl>(getDecl(*iter));
15311529
}
15321530

15331531
TypeDecl *ModuleFile::lookupNestedType(Identifier name,
@@ -2015,11 +2013,8 @@ ModuleFile::getLocalTypeDecls(SmallVectorImpl<TypeDecl *> &results) {
20152013
if (!LocalTypeDecls)
20162014
return;
20172015

2018-
for (auto entry : LocalTypeDecls->data()) {
2019-
auto DeclID = entry.first;
2016+
for (auto DeclID : LocalTypeDecls->data()) {
20202017
auto TD = cast<TypeDecl>(getDecl(DeclID));
2021-
assert(entry.second == TD->getLocalDiscriminator());
2022-
// TD->setLocalDiscriminator(entry.second);
20232018
results.push_back(TD);
20242019
}
20252020
}

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

@@ -4913,9 +4912,7 @@ void Serializer::writeAST(ModuleOrSourceFile DC,
49134912
Mangle::ASTMangler Mangler;
49144913
std::string MangledName = Mangler.mangleDeclAsUSR(TD, /*USRPrefix*/"");
49154914
assert(!MangledName.empty() && "Mangled type came back empty!");
4916-
localTypeGenerator.insert(MangledName, {
4917-
addDeclRef(TD), TD->getLocalDiscriminator()
4918-
});
4915+
localTypeGenerator.insert(MangledName, addDeclRef(TD));
49194916

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

0 commit comments

Comments
 (0)