From ea96f3477cec5289cf0fd68eaec43a270a24b2de Mon Sep 17 00:00:00 2001 From: Allan Shortlidge Date: Fri, 16 Sep 2022 16:04:51 -0700 Subject: [PATCH] SILGen: Function availability for linkage should use `@_backDeploy` OS version if present. When computing the availability of a `SILFunction` for linkage the OS version specified in the `@_backDeploy` attribute should be preferred over the version in the `@available` attribute. This ensures that the corresponding symbol is weakly linked when deploying to older OSes than the back deploy "before" version. Resolves rdar://99962885 --- include/swift/AST/Attr.h | 3 +++ include/swift/AST/Decl.h | 2 +- include/swift/SIL/SILDeclRef.h | 6 ++++- lib/AST/Attr.cpp | 4 ++++ lib/AST/Decl.cpp | 17 +++++++++----- lib/SIL/IR/SILDeclRef.cpp | 10 +++++++++ lib/SIL/IR/SILFunctionBuilder.cpp | 4 +++- lib/SILGen/SILGenBackDeploy.cpp | 3 +-- test/IRGen/weak_import_back_deploy_attr.swift | 22 +++++++++++++++++++ .../back_deploy_attribute_accessor.swift | 6 ++--- ..._deploy_attribute_accessor_coroutine.swift | 6 ++--- test/SILGen/back_deploy_attribute_func.swift | 12 +++++----- .../back_deploy_attribute_generic_func.swift | 6 ++--- .../back_deploy_attribute_struct_method.swift | 6 ++--- .../back_deploy_attribute_throwing_func.swift | 6 ++--- test/attr/attr_backDeploy_evolution.swift | 9 ++++---- 16 files changed, 87 insertions(+), 35 deletions(-) create mode 100644 test/IRGen/weak_import_back_deploy_attr.swift diff --git a/include/swift/AST/Attr.h b/include/swift/AST/Attr.h index 1a49d388c2267..dafe2ea6ce93a 100644 --- a/include/swift/AST/Attr.h +++ b/include/swift/AST/Attr.h @@ -2197,6 +2197,9 @@ class BackDeployAttr: public DeclAttribute { /// The earliest platform version that may use the back deployed implementation. const llvm::VersionTuple Version; + /// Returns true if this attribute is active given the current platform. + bool isActivePlatform(const ASTContext &ctx) const; + static bool classof(const DeclAttribute *DA) { return DA->getKind() == DAK_BackDeploy; } diff --git a/include/swift/AST/Decl.h b/include/swift/AST/Decl.h index a0e7a0182a7c1..1edf68c8023c5 100644 --- a/include/swift/AST/Decl.h +++ b/include/swift/AST/Decl.h @@ -836,7 +836,7 @@ class alignas(1 << DeclAlignInBits) Decl : public ASTAllocated { /// Returns the OS version in which the decl became ABI as specified by the /// @_backDeploy attribute. Optional - getBackDeployBeforeOSVersion(PlatformKind Kind) const; + getBackDeployBeforeOSVersion(ASTContext &Ctx) const; /// Returns the starting location of the entire declaration. SourceLoc getStartLoc() const { return getSourceRange().Start; } diff --git a/include/swift/SIL/SILDeclRef.h b/include/swift/SIL/SILDeclRef.h index bb09daffbc96e..c2f87658164ea 100644 --- a/include/swift/SIL/SILDeclRef.h +++ b/include/swift/SIL/SILDeclRef.h @@ -19,11 +19,12 @@ #ifndef SWIFT_SIL_SILDeclRef_H #define SWIFT_SIL_SILDeclRef_H +#include "swift/AST/Availability.h" #include "swift/AST/ClangNode.h" #include "swift/AST/GenericSignature.h" #include "swift/AST/TypeAlignments.h" -#include "llvm/ADT/Hashing.h" #include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/Hashing.h" #include "llvm/ADT/PointerUnion.h" #include "llvm/Support/PrettyStackTrace.h" @@ -530,6 +531,9 @@ struct SILDeclRef { static AbstractFunctionDecl *getOverriddenWitnessTableEntry( AbstractFunctionDecl *func); + /// Returns the availability of the decl for computing linkage. + Optional getAvailabilityForLinkage() const; + /// True if the referenced entity is some kind of thunk. bool isThunk() const; diff --git a/lib/AST/Attr.cpp b/lib/AST/Attr.cpp index 12060e4eb9429..c06934781b732 100644 --- a/lib/AST/Attr.cpp +++ b/lib/AST/Attr.cpp @@ -1683,6 +1683,10 @@ bool AvailableAttr::isActivePlatform(const ASTContext &ctx) const { return isPlatformActive(Platform, ctx.LangOpts); } +bool BackDeployAttr::isActivePlatform(const ASTContext &ctx) const { + return isPlatformActive(Platform, ctx.LangOpts); +} + AvailableAttr *AvailableAttr::clone(ASTContext &C, bool implicit) const { return new (C) AvailableAttr(implicit ? SourceLoc() : AtLoc, implicit ? SourceRange() : getRange(), diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index f6649314e4582..75b99a22e739c 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -378,10 +378,10 @@ Decl::getIntroducedOSVersion(PlatformKind Kind) const { } Optional -Decl::getBackDeployBeforeOSVersion(PlatformKind Kind) const { +Decl::getBackDeployBeforeOSVersion(ASTContext &Ctx) const { for (auto *attr : getAttrs()) { if (auto *backDeployAttr = dyn_cast(attr)) { - if (backDeployAttr->Platform == Kind && backDeployAttr->Version) { + if (backDeployAttr->isActivePlatform(Ctx) && backDeployAttr->Version) { return backDeployAttr->Version; } } @@ -389,7 +389,8 @@ Decl::getBackDeployBeforeOSVersion(PlatformKind Kind) const { // Accessors may inherit `@_backDeploy`. if (getKind() == DeclKind::Accessor) { - return cast(this)->getStorage()->getBackDeployBeforeOSVersion(Kind); + return cast(this)->getStorage()->getBackDeployBeforeOSVersion( + Ctx); } return None; @@ -927,14 +928,20 @@ bool Decl::isStdlibDecl() const { } AvailabilityContext Decl::getAvailabilityForLinkage() const { + ASTContext &ctx = getASTContext(); + + // When computing availability for linkage, use the "before" version from + // the @_backDeploy attribute, if present. + if (auto backDeployVersion = getBackDeployBeforeOSVersion(ctx)) + return AvailabilityContext{VersionRange::allGTE(*backDeployVersion)}; + auto containingContext = AvailabilityInference::annotatedAvailableRange(this, getASTContext()); if (containingContext.hasValue()) { - // If this entity comes from the concurrency module, adjust it's + // If this entity comes from the concurrency module, adjust its // availability for linkage purposes up to Swift 5.5, so that we use // weak references any time we reference those symbols when back-deploying // concurrency. - ASTContext &ctx = getASTContext(); if (getModuleContext()->getName() == ctx.Id_Concurrency) { containingContext->intersectWith(ctx.getConcurrencyAvailability()); } diff --git a/lib/SIL/IR/SILDeclRef.cpp b/lib/SIL/IR/SILDeclRef.cpp index 291bce81076ad..ffae470870d60 100644 --- a/lib/SIL/IR/SILDeclRef.cpp +++ b/lib/SIL/IR/SILDeclRef.cpp @@ -207,6 +207,16 @@ ASTContext &SILDeclRef::getASTContext() const { llvm_unreachable("Unhandled case in switch"); } +Optional SILDeclRef::getAvailabilityForLinkage() const { + // Back deployment thunks and fallbacks don't have availability since they + // are non-ABI. + // FIXME: Generalize this check to all kinds of non-ABI functions. + if (backDeploymentKind != SILDeclRef::BackDeploymentKind::None) + return None; + + return getDecl()->getAvailabilityForLinkage(); +} + bool SILDeclRef::isThunk() const { return isForeignToNativeThunk() || isNativeToForeignThunk() || isDistributedThunk() || isBackDeploymentThunk(); diff --git a/lib/SIL/IR/SILFunctionBuilder.cpp b/lib/SIL/IR/SILFunctionBuilder.cpp index e9b5743a4453f..76c8368e42709 100644 --- a/lib/SIL/IR/SILFunctionBuilder.cpp +++ b/lib/SIL/IR/SILFunctionBuilder.cpp @@ -311,7 +311,9 @@ SILFunction *SILFunctionBuilder::getOrCreateFunction( if (constant.isForeign && decl->hasClangNode()) F->setClangNodeOwner(decl); - F->setAvailabilityForLinkage(decl->getAvailabilityForLinkage()); + if (auto availability = constant.getAvailabilityForLinkage()) + F->setAvailabilityForLinkage(*availability); + F->setAlwaysWeakImported(decl->isAlwaysWeakImported()); if (auto *accessor = dyn_cast(decl)) { diff --git a/lib/SILGen/SILGenBackDeploy.cpp b/lib/SILGen/SILGenBackDeploy.cpp index d8703055bced5..8ac9ee5d14637 100644 --- a/lib/SILGen/SILGenBackDeploy.cpp +++ b/lib/SILGen/SILGenBackDeploy.cpp @@ -52,8 +52,7 @@ static void emitBackDeployIfAvailableCondition(SILGenFunction &SGF, SILLocation loc, SILBasicBlock *availableBB, SILBasicBlock *unavailableBB) { - PlatformKind platform = targetPlatform(SGF.SGM.getASTContext().LangOpts); - auto version = AFD->getBackDeployBeforeOSVersion(platform); + auto version = AFD->getBackDeployBeforeOSVersion(SGF.SGM.getASTContext()); VersionRange OSVersion = VersionRange::empty(); if (version.hasValue()) { OSVersion = VersionRange::allGTE(*version); diff --git a/test/IRGen/weak_import_back_deploy_attr.swift b/test/IRGen/weak_import_back_deploy_attr.swift new file mode 100644 index 0000000000000..27493c8315a5b --- /dev/null +++ b/test/IRGen/weak_import_back_deploy_attr.swift @@ -0,0 +1,22 @@ +// RUN: %empty-directory(%t) +// RUN: split-file %s %t +// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Library.swiftmodule -parse-as-library %t/Library.swift -enable-library-evolution + +// RUN: %target-swift-frontend -primary-file %t/Client.swift -I %t -emit-ir -target %target-cpu-apple-macosx10.50 | %FileCheck %t/Client.swift --check-prefix=CHECK-OLD +// RUN: %target-swift-frontend -primary-file %t/Client.swift -I %t -emit-ir -target %target-cpu-apple-macosx10.60 | %FileCheck %t/Client.swift --check-prefix=CHECK-NEW + +// REQUIRES: OS=macosx + +//--- Library.swift + +@available(macOS 10.50, *) +@_backDeploy(before: macOS 10.60) +public func backDeployedFunc() {} + +//--- Client.swift + +import Library + +// CHECK-OLD: declare extern_weak {{.*}} void @"$s7Library16backDeployedFuncyyF"() +// CHECK-NEW: declare {{.*}} void @"$s7Library16backDeployedFuncyyF"() +backDeployedFunc() diff --git a/test/SILGen/back_deploy_attribute_accessor.swift b/test/SILGen/back_deploy_attribute_accessor.swift index 77195f24349b1..b71fe153da34e 100644 --- a/test/SILGen/back_deploy_attribute_accessor.swift +++ b/test/SILGen/back_deploy_attribute_accessor.swift @@ -8,12 +8,12 @@ @available(macOS 10.50, *) public struct TopLevelStruct { // -- Fallback definition for TopLevelStruct.property.getter - // CHECK-LABEL: sil non_abi [serialized] [available 10.51] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvgTwB : $@convention(method) (TopLevelStruct) -> TopLevelStruct + // CHECK-LABEL: sil non_abi [serialized] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvgTwB : $@convention(method) (TopLevelStruct) -> TopLevelStruct // CHECK: bb0([[SELF:%.*]] : $TopLevelStruct): // CHECK: return [[SELF]] : $TopLevelStruct // -- Back deployment thunk for TopLevelStruct.property.getter - // CHECK-LABEL: sil non_abi [serialized] [thunk] [available 10.51] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvgTwb : $@convention(method) (TopLevelStruct) -> TopLevelStruct + // CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvgTwb : $@convention(method) (TopLevelStruct) -> TopLevelStruct // CHECK: bb0([[BB0_ARG:%.*]] : $TopLevelStruct): // CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 10 // CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 52 @@ -36,7 +36,7 @@ public struct TopLevelStruct { // CHECK: return [[RETURN_BB_ARG]] : $TopLevelStruct // -- Original definition of TopLevelStruct.property.getter - // CHECK-LABEL: sil [available 10.51] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvg : $@convention(method) (TopLevelStruct) -> TopLevelStruct + // CHECK-LABEL: sil [available 10.52] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvg : $@convention(method) (TopLevelStruct) -> TopLevelStruct @available(macOS 10.51, *) @_backDeploy(before: macOS 10.52) public var property: TopLevelStruct { self } diff --git a/test/SILGen/back_deploy_attribute_accessor_coroutine.swift b/test/SILGen/back_deploy_attribute_accessor_coroutine.swift index 910008ffaff93..9a3cc12a24d9b 100644 --- a/test/SILGen/back_deploy_attribute_accessor_coroutine.swift +++ b/test/SILGen/back_deploy_attribute_accessor_coroutine.swift @@ -8,7 +8,7 @@ @available(macOS 10.50, *) public struct TopLevelStruct { // -- Fallback definition for TopLevelStruct.property.read - // CHECK-LABEL: sil non_abi [serialized] [available 10.51] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvrTwB : $@yield_once @convention(method) (TopLevelStruct) -> @yields TopLevelStruct + // CHECK-LABEL: sil non_abi [serialized] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvrTwB : $@yield_once @convention(method) (TopLevelStruct) -> @yields TopLevelStruct // CHECK: bb0([[BB0_ARG:%.*]] : $TopLevelStruct): // CHECK: yield [[BB0_ARG]] : $TopLevelStruct, resume [[RESUME_BB:bb[0-9]+]], unwind [[UNWIND_BB:bb[0-9]+]] // @@ -20,7 +20,7 @@ public struct TopLevelStruct { // CHECK: unwind // -- Back deployment thunk for TopLevelStruct.property.read - // CHECK-LABEL: sil non_abi [serialized] [thunk] [available 10.51] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvrTwb : $@yield_once @convention(method) (TopLevelStruct) -> @yields TopLevelStruct + // CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvrTwb : $@yield_once @convention(method) (TopLevelStruct) -> @yields TopLevelStruct // CHECK: bb0([[BB0_ARG:%.*]] : $TopLevelStruct): // CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 10 // CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 52 @@ -63,7 +63,7 @@ public struct TopLevelStruct { // CHECK: unwind // -- Original definition of TopLevelStruct.property.read - // CHECK-LABEL: sil [available 10.51] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvr : $@yield_once @convention(method) (TopLevelStruct) -> @yields TopLevelStruct + // CHECK-LABEL: sil [available 10.52] [ossa] @$s11back_deploy14TopLevelStructV8propertyACvr : $@yield_once @convention(method) (TopLevelStruct) -> @yields TopLevelStruct @available(macOS 10.51, *) @_backDeploy(before: macOS 10.52) public var property: TopLevelStruct { diff --git a/test/SILGen/back_deploy_attribute_func.swift b/test/SILGen/back_deploy_attribute_func.swift index 77d1b0403a0d1..e5c1a84fa3df8 100644 --- a/test/SILGen/back_deploy_attribute_func.swift +++ b/test/SILGen/back_deploy_attribute_func.swift @@ -6,13 +6,13 @@ // REQUIRES: OS=macosx // -- Fallback definition of trivialFunc() -// CHECK-LABEL: sil non_abi [serialized] [available 10.51] [ossa] @$s11back_deploy11trivialFuncyyFTwB : $@convention(thin) () -> () +// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s11back_deploy11trivialFuncyyFTwB : $@convention(thin) () -> () // CHECK: bb0: // CHECK: [[RESULT:%.*]] = tuple () // CHECK: return [[RESULT]] : $() // -- Back deployment thunk for trivialFunc() -// CHECK-LABEL: sil non_abi [serialized] [thunk] [available 10.51] [ossa] @$s11back_deploy11trivialFuncyyFTwb : $@convention(thin) () -> () +// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy11trivialFuncyyFTwb : $@convention(thin) () -> () // CHECK: bb0: // CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 10 // CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 52 @@ -36,19 +36,19 @@ // CHECK: return [[RESULT]] : $() // -- Original definition of trivialFunc() -// CHECK-LABEL: sil [available 10.51] [ossa] @$s11back_deploy11trivialFuncyyF : $@convention(thin) () -> () +// CHECK-LABEL: sil [available 10.52] [ossa] @$s11back_deploy11trivialFuncyyF : $@convention(thin) () -> () @available(macOS 10.51, *) @_backDeploy(before: macOS 10.52) public func trivialFunc() {} // -- Fallback definition of isNumber(_:) -// CHECK-LABEL: sil non_abi [serialized] [available 10.51] [ossa] @$s11back_deploy8isNumberySbSiFTwB : $@convention(thin) (Int) -> Bool +// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s11back_deploy8isNumberySbSiFTwB : $@convention(thin) (Int) -> Bool // CHECK: bb0([[ARG_X:%.*]] : $Int): // ... // CHECK: return {{%.*}} : $Bool // -- Back deployment thunk for isNumber(_:) -// CHECK-LABEL: sil non_abi [serialized] [thunk] [available 10.51] [ossa] @$s11back_deploy8isNumberySbSiFTwb : $@convention(thin) (Int) -> Bool +// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy8isNumberySbSiFTwb : $@convention(thin) (Int) -> Bool // CHECK: bb0([[ARG_X:%.*]] : $Int): // CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 10 // CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 52 @@ -71,7 +71,7 @@ public func trivialFunc() {} // CHECK: return [[RETURN_BB_ARG]] : $Bool // -- Original definition of isNumber(_:) -// CHECK-LABEL: sil [available 10.51] [ossa] @$s11back_deploy8isNumberySbSiF : $@convention(thin) (Int) -> Bool +// CHECK-LABEL: sil [available 10.52] [ossa] @$s11back_deploy8isNumberySbSiF : $@convention(thin) (Int) -> Bool @available(macOS 10.51, *) @_backDeploy(before: macOS 10.52) public func isNumber(_ x: Int) -> Bool { diff --git a/test/SILGen/back_deploy_attribute_generic_func.swift b/test/SILGen/back_deploy_attribute_generic_func.swift index 2dd2a721aff31..fd1d8ab784526 100644 --- a/test/SILGen/back_deploy_attribute_generic_func.swift +++ b/test/SILGen/back_deploy_attribute_generic_func.swift @@ -6,14 +6,14 @@ // REQUIRES: OS=macosx // -- Fallback definition of genericFunc() -// CHECK-LABEL: sil non_abi [serialized] [available 10.51] [ossa] @$s11back_deploy11genericFuncyxxlFTwB : $@convention(thin) (@in_guaranteed T) -> @out T +// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s11back_deploy11genericFuncyxxlFTwB : $@convention(thin) (@in_guaranteed T) -> @out T // CHECK: bb0([[OUT_ARG:%.*]] : $*T, [[IN_ARG:%.*]] : $*T): // CHECK: copy_addr [[IN_ARG]] to [initialization] [[OUT_ARG]] : $*T // CHECK: [[RESULT:%.*]] = tuple () // CHECK: return [[RESULT]] : $() // -- Back deployment thunk for genericFunc() -// CHECK-LABEL: sil non_abi [serialized] [thunk] [available 10.51] [ossa] @$s11back_deploy11genericFuncyxxlFTwb : $@convention(thin) (@in_guaranteed T) -> @out T +// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy11genericFuncyxxlFTwb : $@convention(thin) (@in_guaranteed T) -> @out T // CHECK: bb0([[OUT_ARG:%.*]] : $*T, [[IN_ARG:%.*]] : $*T): // CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 10 // CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 52 @@ -37,7 +37,7 @@ // CHECK: return [[RESULT]] : $() // -- Original definition of genericFunc() -// CHECK-LABEL: sil [available 10.51] [ossa] @$s11back_deploy11genericFuncyxxlF : $@convention(thin) (@in_guaranteed T) -> @out T +// CHECK-LABEL: sil [available 10.52] [ossa] @$s11back_deploy11genericFuncyxxlF : $@convention(thin) (@in_guaranteed T) -> @out T @available(macOS 10.51, *) @_backDeploy(before: macOS 10.52) public func genericFunc(_ t: T) -> T { diff --git a/test/SILGen/back_deploy_attribute_struct_method.swift b/test/SILGen/back_deploy_attribute_struct_method.swift index ca7bb8e6815fa..054fd24cf2027 100644 --- a/test/SILGen/back_deploy_attribute_struct_method.swift +++ b/test/SILGen/back_deploy_attribute_struct_method.swift @@ -8,13 +8,13 @@ @available(macOS 10.50, *) public struct TopLevelStruct { // -- Fallback definition for TopLevelStruct.trivialMethod() - // CHECK-LABEL: sil non_abi [serialized] [available 10.51] [ossa] @$s11back_deploy14TopLevelStructV13trivialMethodyyFTwB : $@convention(method) (TopLevelStruct) -> () + // CHECK-LABEL: sil non_abi [serialized] [ossa] @$s11back_deploy14TopLevelStructV13trivialMethodyyFTwB : $@convention(method) (TopLevelStruct) -> () // CHECK: bb0({{%.*}} : $TopLevelStruct): // CHECK: [[RESULT:%.*]] = tuple () // CHECK: return [[RESULT]] : $() // -- Back deployment thunk for TopLevelStruct.trivialMethod() - // CHECK-LABEL: sil non_abi [serialized] [thunk] [available 10.51] [ossa] @$s11back_deploy14TopLevelStructV13trivialMethodyyFTwb : $@convention(method) (TopLevelStruct) -> () + // CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy14TopLevelStructV13trivialMethodyyFTwb : $@convention(method) (TopLevelStruct) -> () // CHECK: bb0([[BB0_ARG:%.*]] : $TopLevelStruct): // CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 10 // CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 52 @@ -38,7 +38,7 @@ public struct TopLevelStruct { // CHECK: return [[RESULT]] : $() // -- Original definition of TopLevelStruct.trivialMethod() - // CHECK-LABEL: sil [available 10.51] [ossa] @$s11back_deploy14TopLevelStructV13trivialMethodyyF : $@convention(method) (TopLevelStruct) -> () + // CHECK-LABEL: sil [available 10.52] [ossa] @$s11back_deploy14TopLevelStructV13trivialMethodyyF : $@convention(method) (TopLevelStruct) -> () @available(macOS 10.51, *) @_backDeploy(before: macOS 10.52) public func trivialMethod() {} diff --git a/test/SILGen/back_deploy_attribute_throwing_func.swift b/test/SILGen/back_deploy_attribute_throwing_func.swift index be5baded56f7f..75d205f2f239a 100644 --- a/test/SILGen/back_deploy_attribute_throwing_func.swift +++ b/test/SILGen/back_deploy_attribute_throwing_func.swift @@ -6,13 +6,13 @@ // REQUIRES: OS=macosx // -- Fallback definition of throwingFunc() -// CHECK-LABEL: sil non_abi [serialized] [available 10.51] [ossa] @$s11back_deploy12throwingFuncyyKFTwB : $@convention(thin) () -> @error Error +// CHECK-LABEL: sil non_abi [serialized] [ossa] @$s11back_deploy12throwingFuncyyKFTwB : $@convention(thin) () -> @error Error // CHECK: bb0: // CHECK: [[RESULT:%.*]] = tuple () // CHECK: return [[RESULT]] : $() // -- Back deployment thunk for throwingFunc() -// CHECK-LABEL: sil non_abi [serialized] [thunk] [available 10.51] [ossa] @$s11back_deploy12throwingFuncyyKFTwb : $@convention(thin) () -> @error Error +// CHECK-LABEL: sil non_abi [serialized] [thunk] [ossa] @$s11back_deploy12throwingFuncyyKFTwb : $@convention(thin) () -> @error Error // CHECK: bb0: // CHECK: [[MAJOR:%.*]] = integer_literal $Builtin.Word, 10 // CHECK: [[MINOR:%.*]] = integer_literal $Builtin.Word, 52 @@ -49,7 +49,7 @@ // CHECK: throw [[RETHROW_BB_ARG]] : $Error // -- Original definition of throwingFunc() -// CHECK-LABEL: sil [available 10.51] [ossa] @$s11back_deploy12throwingFuncyyKF : $@convention(thin) () -> @error Error +// CHECK-LABEL: sil [available 10.52] [ossa] @$s11back_deploy12throwingFuncyyKF : $@convention(thin) () -> @error Error @available(macOS 10.51, *) @_backDeploy(before: macOS 10.52) public func throwingFunc() throws {} diff --git a/test/attr/attr_backDeploy_evolution.swift b/test/attr/attr_backDeploy_evolution.swift index 87bcf5e756808..0ec4c732371c0 100644 --- a/test/attr/attr_backDeploy_evolution.swift +++ b/test/attr/attr_backDeploy_evolution.swift @@ -62,7 +62,7 @@ // ---- (3) Run executable // RUN: %target-codesign %t/test_ABI -// RUN: %target-run %t/test_ABI %t/SDK_ABI/Frameworks/BackDeployHelper.framework/BackDeployHelper | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-ABI %s +// RUN: %target-run %t/test_ABI | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-ABI %s // ---- (4) Build famework with BackDeploy 2.0 in the future // RUN: mkdir -p %t/SDK_BD/Frameworks/BackDeployHelper.framework/Modules/BackDeployHelper.swiftmodule @@ -89,9 +89,10 @@ // ---- (6) Run executable // RUN: %target-codesign %t/test_BD -// RUN: %target-run %t/test_BD %t/SDK_BD/Frameworks/BackDeployHelper.framework/BackDeployHelper | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-BD %s +// RUN: %target-run %t/test_BD | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-BD %s -// ---- (7) Re-build famework with the back deployed APIs stripped +// ---- (7) Re-build framework with the back deployed APIs stripped +// RUN: %empty-directory(%t/SDK_BD) // RUN: mkdir -p %t/SDK_BD/Frameworks/BackDeployHelper.framework/Modules/BackDeployHelper.swiftmodule // RUN: %target-build-swift-dylib(%t/SDK_BD/Frameworks/BackDeployHelper.framework/BackDeployHelper) \ // RUN: -emit-module-path %t/SDK_BD/Frameworks/BackDeployHelper.framework/Modules/BackDeployHelper.swiftmodule/%module-target-triple.swiftmodule \ @@ -106,7 +107,7 @@ // ---- (8) Re-run executable // RUN: %target-codesign %t/test_BD -// RUN: %target-run %t/test_BD %t/SDK_BD/Frameworks/BackDeployHelper.framework/BackDeployHelper | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-BD %s +// RUN: %target-run %t/test_BD | %FileCheck --check-prefix=CHECK --check-prefix=CHECK-BD %s import BackDeployHelper