Skip to content

SIL Deserializer: Don't deserialize during "lowered" stage. #15766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/SIL/SILModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,18 @@ SILModule::lookUpWitnessTable(const ProtocolConformance *C,
if (wtable->isDefinition())
return wtable;

// If the module is at or past the Lowered stage, then we can't do any
// further deserialization, since pre-IRGen SIL lowering changes the types
// of definitions to make them incompatible with canonical serialized SIL.
switch (getStage()) {
case SILStage::Canonical:
case SILStage::Raw:
break;

case SILStage::Lowered:
return wtable;
}

// Otherwise try to deserialize it. If we succeed return the deserialized
// function.
//
Expand Down
13 changes: 13 additions & 0 deletions lib/Serialization/DeserializeSIL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,19 @@ SILFunction *SILDeserializer::readSILFunction(DeclID FID,
StringRef name,
bool declarationOnly,
bool errorIfEmptyBody) {
// We can't deserialize function bodies after IRGen lowering passes have
// happened since other definitions in the module will no longer be in
// canonical SIL form.
switch (SILMod.getStage()) {
case SILStage::Raw:
case SILStage::Canonical:
break;

case SILStage::Lowered:
llvm_unreachable("cannot deserialize into a module that has entered "
"Lowered stage");
}

if (FID == 0)
return nullptr;
assert(FID <= Funcs.size() && "invalid SILFunction ID");
Expand Down