Skip to content

[WIP] SIL serialization recovery for instructions #17570

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

Conversation

jrose-apple
Copy link
Contributor

When instructions in an inlinable SIL function can't be deserialized, drop the body of the function and make it external. This commit tests that behavior by making several simple classes of SILInstruction recover from their types not being deserializable.

Builds on #17564; this is the more interesting part.

Still to do:

  • Many more instruction kinds
  • Cascading failures: if a 'shared' function can't be deserialized, anything that references it should also fail.
  • Produce an error in SIL diagnostics if the function that got dropped was an always-emit-into-client function, and thus cannot be marked external.

Part of rdar://problem/40899824

Now that @inlinable is a supported feature, we need to handle cases
where a function is inlinable but it references some type that imports
differently in different Swift versions. To start, handle the case
where a SIL function's type is now invalid and therefore the entire
function can't be imported. This doesn't open up anything interesting
yet, but it's a start.

Part of rdar://problem/40899824
When instructions in an inlinable SIL function can't be deserialized,
drop the body of the function and make it external. This commit tests
that behavior by making several simple classes of SILInstruction
recover from their types not being deserializable.

Still to do:
- Many more instruction kinds
- Cascading failures: if a 'shared' function can't be deserialized,
  anything that references it should also fail.
- Produce an error in SIL diagnostics if the function that got dropped
  was an always-emit-into-client function, and thus cannot be marked
  external.

Part of rdar://problem/40899824
@@ -1538,16 +1557,21 @@ bool SILDeserializer::readSILInstruction(SILFunction *Fn, SILBasicBlock *BB,
case SILInstructionKind::StringLiteralInst: {
Identifier StringVal = MF->getIdentifier(ValID);
auto encoding = fromStableStringEncoding(Attr);
if (!encoding) return true;
if (!encoding) {
MF->error();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should MF->error() be [[unreachable]] or whatever?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:-/ It's stateful at the moment—if you error early on in loading the module, it records that information for use later and compilation can keep going. I should probably go rework that at some point so that the recoverable parts go through a different entry point.

@shahmishal
Copy link
Member

Please update the base branch to main by Oct 5th otherwise the pull request will be closed automatically.

  • How to change the base branch: (Link)
  • More detail about the branch update: (Link)

@shahmishal shahmishal closed this Oct 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants