From e0cce4a45d3aa16a260d34a2eaf33c11b37f447b Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Tue, 6 Dec 2022 17:08:42 -0800 Subject: [PATCH] Serialization: Update `-experimental-skip-non-inlinable-function-bodies` SIL verification for `@_backDeploy`. SIL verification was failing for modules containing functions with `@_backDeploy` because `SILSkippingChecker` expected the `SILFunction` corresponding to the resilient copy of back deployed function to be empty. Since the overall function declaration for a back deployed function is considered inlinable, the body will be typechecked and SILGen emits both the fallback copy of the function and the resilient copy of the function. The checker should therefore expect to see back deployed functions that are not marked as serialized. --- lib/SILOptimizer/UtilityPasses/SILSkippingChecker.cpp | 9 +++++++++ ...deployed-attr-skip-noninlinable-function-bodies.swift | 5 +++++ 2 files changed, 14 insertions(+) create mode 100644 test/Serialization/back-deployed-attr-skip-noninlinable-function-bodies.swift diff --git a/lib/SILOptimizer/UtilityPasses/SILSkippingChecker.cpp b/lib/SILOptimizer/UtilityPasses/SILSkippingChecker.cpp index 93e0cb2b952af..da5d8218cc404 100644 --- a/lib/SILOptimizer/UtilityPasses/SILSkippingChecker.cpp +++ b/lib/SILOptimizer/UtilityPasses/SILSkippingChecker.cpp @@ -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()) + 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. diff --git a/test/Serialization/back-deployed-attr-skip-noninlinable-function-bodies.swift b/test/Serialization/back-deployed-attr-skip-noninlinable-function-bodies.swift new file mode 100644 index 0000000000000..ae355a0980cb1 --- /dev/null +++ b/test/Serialization/back-deployed-attr-skip-noninlinable-function-bodies.swift @@ -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() {}