Skip to content

Serialization: Update -experimental-skip-non-inlinable-function-bodies SIL verification for @_backDeploy #62427

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
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
9 changes: 9 additions & 0 deletions lib/SILOptimizer/UtilityPasses/SILSkippingChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ static bool shouldHaveSkippedFunction(const SILFunction &F) {
return false;
}

// Functions with @_backDeploy may be copied into the client, so they
// shouldn't be skipped. The SILFunction that may be copied into the client
// should be serialized and therefore is already handled above. However, a
// second resilient SILFunction is also emitted for back deployed functions.
// Since the body of the function as written was not skipped, it's expected
// that we see the SILFunction for the resilient copy here.
if (func->isBackDeployed())
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems a little bit odd for me that we need to check BackDeployed specifically here but not for other attributes like @_alwaysEmitIntoClient.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@_backDeployed is special for the reasons described in the comment and in the PR description. Maybe there's a way I can describe this in a clearer way. @inlinable, AEIC, @_transparent are all handled by the if (F.isSerialized()) check at the top of this function. @_backDeployed causes two SILFunctions to be emitted. One of them passes the if (F.isSerialized()) check. The other (representing the resilient copy of the function) is the one we need to handle here.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, makes sense. Thank you for the clarification!

return false;

// If none of those conditions trip, then this is something that _should_
// be serialized in the module even when we're skipping non-inlinable
// function bodies.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// RUN: %target-swift-frontend -parse-as-library -enable-library-evolution -emit-module -module-name Test -experimental-skip-non-inlinable-function-bodies %s

@available(SwiftStdlib 5.6, *)
@_backDeploy(before: SwiftStdlib 5.7)
public func foo() {}