From e415c1a42fcd7d2fd6bb9fabd25ade69b390336f Mon Sep 17 00:00:00 2001 From: Arnold Schwaighofer Date: Mon, 20 May 2024 08:41:06 -0700 Subject: [PATCH] [SIL] [Package CMO] Remove resilience bailout that is an artifact of incremental development --- lib/SIL/IR/SILFunction.cpp | 11 ---------- .../package-cmo-resilient-mode.swift | 21 ++++++++++++++++++- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/lib/SIL/IR/SILFunction.cpp b/lib/SIL/IR/SILFunction.cpp index d1f19eae0bef9..8834a969e5e5e 100644 --- a/lib/SIL/IR/SILFunction.cpp +++ b/lib/SIL/IR/SILFunction.cpp @@ -548,17 +548,6 @@ bool SILFunction::isNoReturnFunction(TypeExpansionContext context) const { } ResilienceExpansion SILFunction::getResilienceExpansion() const { - // If package serialization is enabled, we can safely - // assume that the defining .swiftmodule is built from - // source and is never used outside of its package; - // Even if the module is built resiliently, return - // maximal expansion here so aggregate types can be - // treated as loadable in the same resilient domain - // (across modules in the same package). - if (getModule().getSwiftModule()->serializePackageEnabled() && - getModule().getSwiftModule()->isResilient()) - return ResilienceExpansion::Maximal; - // If a function definition is in another module, and // it was serialized due to package serialization opt, // a new attribute [serialized_for_package] is added diff --git a/test/SILOptimizer/package-cmo-resilient-mode.swift b/test/SILOptimizer/package-cmo-resilient-mode.swift index e1b7d6a8e2117..b10a06191fc44 100644 --- a/test/SILOptimizer/package-cmo-resilient-mode.swift +++ b/test/SILOptimizer/package-cmo-resilient-mode.swift @@ -239,7 +239,7 @@ public func runPub(_ arg: PubStruct) -> Int { public func runPubInlinable(_ arg: Int) -> PubStruct { // CHECK-RES-DAG: sil [serialized] [serialized_for_package] [canonical] @$s3Lib15runPubInlinableyAA0C6StructVSiF : $@convention(thin) (Int) -> @out PubStruct { // CHECK-NONRES-DAG: sil [serialized] [canonical] @$s3Lib15runPubInlinableyAA0C6StructVSiF : $@convention(thin) (Int) -> PubStruct { - // CHECK-RES-DAG: alloc_stack [var_decl] $PubStruct + // CHECK-RES-DAG: alloc_stack {{.*}} [var_decl] $PubStruct // CHECK-RES-DAG: function_ref @$s3Lib9PubStructVyACSicfC : $@convention(method) (Int, @thin PubStruct.Type) -> @out PubStruct // CHECK-NONRES-DAG: function_ref @$s3Lib9PubStructVyACSicfC : $@convention(method) (Int, @thin PubStruct.Type) -> PubStruct var x = PubStruct(1) @@ -485,3 +485,22 @@ final package class FinalPkgKlass { // CHECK-COMMON-NEXT: method #PkgProto.data!setter: (inout Self) -> (Int) -> () : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivsTW // CHECK-COMMON-NEXT: method #PkgProto.data!modify: (inout Self) -> () -> () : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivMTW // CHECK-COMMON-NEXT: method #PkgProto.pkgfunc: (Self) -> (Int) -> Int : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP7pkgfuncyS2iFTW + +public struct Something { + public init() {} + + public func f() -> Int { + return 7 + } +} + +@usableFromInline +func use(_ c: () -> Int) { } + +// Don't crash on this example +@inlinable +public func reproduce(_ e: Something) { + use { + return e.f() + } +}