mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Summon the eldritch horror "EagerDeserializationDecls" from the bowels of history.
Adding explicit constructors to Clang-imported structs in the previous commits exposes a latent phase ordering issue between the Clang importer and SIL deserialization. Deserializing the standard library SIL ends up pulling in additional Clang decls which never get type-checked before we attempt to emit their code. Work around this by bringing back the "EagerDeserializedDecls" block in the serialization format, and adding any cross-referenced decls that get referenced in SILSerializeAll mode to it, so that we ensure they're available before SILGen. We also have to type-check external decls after doing so, since when only importing a module, we wouldn't do any type-checking at all otherwise. Swift SVN r23728
This commit is contained in:
@@ -323,6 +323,8 @@ ModuleFile::readObjCMethodTable(ArrayRef<uint64_t> fields, StringRef blobData) {
|
||||
base + sizeof(uint32_t), base));
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool ModuleFile::readIndexBlock(llvm::BitstreamCursor &cursor) {
|
||||
cursor.EnterSubBlock(INDEX_BLOCK_ID);
|
||||
|
||||
@@ -378,6 +380,11 @@ bool ModuleFile::readIndexBlock(llvm::BitstreamCursor &cursor) {
|
||||
break;
|
||||
case index_block::OBJC_METHODS:
|
||||
ObjCMethods = readObjCMethodTable(scratch, blobData);
|
||||
break;
|
||||
case index_block::FORCE_DESERIALIZATION:
|
||||
std::copy(scratch.begin(), scratch.end(),
|
||||
std::back_inserter(EagerDeserializationDecls));
|
||||
|
||||
break;
|
||||
default:
|
||||
// Unknown index kind, which this version of the compiler won't use.
|
||||
@@ -887,6 +894,13 @@ bool ModuleFile::associateWithFileContext(FileUnit *file, SourceLoc diagLoc) {
|
||||
if (Bits.HasUnderlyingModule)
|
||||
(void)getModule(FileContext->getParentModule()->Name);
|
||||
|
||||
// Process decls we know we want to eagerly deserialize.
|
||||
if (!EagerDeserializationDecls.empty()) {
|
||||
for (DeclID DID : EagerDeserializationDecls)
|
||||
getDecl(DID);
|
||||
typeCheckExternalDefinitions(*FileContext);
|
||||
}
|
||||
|
||||
return getStatus() == ModuleStatus::Valid;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user