Skip to content

Commit 78899a5

Browse files
authored
Merge pull request #15766 from jckarter/dont-deserialize-into-lowered-sil
SIL Deserializer: Don't deserialize during "lowered" stage.
2 parents 5e74cda + f24fd24 commit 78899a5

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

lib/SIL/SILModule.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,18 @@ SILModule::lookUpWitnessTable(const ProtocolConformance *C,
186186
if (wtable->isDefinition())
187187
return wtable;
188188

189+
// If the module is at or past the Lowered stage, then we can't do any
190+
// further deserialization, since pre-IRGen SIL lowering changes the types
191+
// of definitions to make them incompatible with canonical serialized SIL.
192+
switch (getStage()) {
193+
case SILStage::Canonical:
194+
case SILStage::Raw:
195+
break;
196+
197+
case SILStage::Lowered:
198+
return wtable;
199+
}
200+
189201
// Otherwise try to deserialize it. If we succeed return the deserialized
190202
// function.
191203
//

lib/Serialization/DeserializeSIL.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -387,6 +387,19 @@ SILFunction *SILDeserializer::readSILFunction(DeclID FID,
387387
StringRef name,
388388
bool declarationOnly,
389389
bool errorIfEmptyBody) {
390+
// We can't deserialize function bodies after IRGen lowering passes have
391+
// happened since other definitions in the module will no longer be in
392+
// canonical SIL form.
393+
switch (SILMod.getStage()) {
394+
case SILStage::Raw:
395+
case SILStage::Canonical:
396+
break;
397+
398+
case SILStage::Lowered:
399+
llvm_unreachable("cannot deserialize into a module that has entered "
400+
"Lowered stage");
401+
}
402+
390403
if (FID == 0)
391404
return nullptr;
392405
assert(FID <= Funcs.size() && "invalid SILFunction ID");

0 commit comments

Comments
 (0)