Skip to content

Commit e415c1a

Browse files
committed
[SIL] [Package CMO] Remove resilience bailout that is an artifact of incremental development
1 parent 72d801c commit e415c1a

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

lib/SIL/IR/SILFunction.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -548,17 +548,6 @@ bool SILFunction::isNoReturnFunction(TypeExpansionContext context) const {
548548
}
549549

550550
ResilienceExpansion SILFunction::getResilienceExpansion() const {
551-
// If package serialization is enabled, we can safely
552-
// assume that the defining .swiftmodule is built from
553-
// source and is never used outside of its package;
554-
// Even if the module is built resiliently, return
555-
// maximal expansion here so aggregate types can be
556-
// treated as loadable in the same resilient domain
557-
// (across modules in the same package).
558-
if (getModule().getSwiftModule()->serializePackageEnabled() &&
559-
getModule().getSwiftModule()->isResilient())
560-
return ResilienceExpansion::Maximal;
561-
562551
// If a function definition is in another module, and
563552
// it was serialized due to package serialization opt,
564553
// a new attribute [serialized_for_package] is added

test/SILOptimizer/package-cmo-resilient-mode.swift

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ public func runPub(_ arg: PubStruct) -> Int {
239239
public func runPubInlinable(_ arg: Int) -> PubStruct {
240240
// CHECK-RES-DAG: sil [serialized] [serialized_for_package] [canonical] @$s3Lib15runPubInlinableyAA0C6StructVSiF : $@convention(thin) (Int) -> @out PubStruct {
241241
// CHECK-NONRES-DAG: sil [serialized] [canonical] @$s3Lib15runPubInlinableyAA0C6StructVSiF : $@convention(thin) (Int) -> PubStruct {
242-
// CHECK-RES-DAG: alloc_stack [var_decl] $PubStruct
242+
// CHECK-RES-DAG: alloc_stack {{.*}} [var_decl] $PubStruct
243243
// CHECK-RES-DAG: function_ref @$s3Lib9PubStructVyACSicfC : $@convention(method) (Int, @thin PubStruct.Type) -> @out PubStruct
244244
// CHECK-NONRES-DAG: function_ref @$s3Lib9PubStructVyACSicfC : $@convention(method) (Int, @thin PubStruct.Type) -> PubStruct
245245
var x = PubStruct(1)
@@ -485,3 +485,22 @@ final package class FinalPkgKlass {
485485
// CHECK-COMMON-NEXT: method #PkgProto.data!setter: <Self where Self : PkgProto> (inout Self) -> (Int) -> () : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivsTW
486486
// CHECK-COMMON-NEXT: method #PkgProto.data!modify: <Self where Self : PkgProto> (inout Self) -> () -> () : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP4dataSivMTW
487487
// CHECK-COMMON-NEXT: method #PkgProto.pkgfunc: <Self where Self : PkgProto> (Self) -> (Int) -> Int : @$s3Lib8PkgKlassCAA0B5ProtoA2aDP7pkgfuncyS2iFTW
488+
489+
public struct Something {
490+
public init() {}
491+
492+
public func f() -> Int {
493+
return 7
494+
}
495+
}
496+
497+
@usableFromInline
498+
func use(_ c: () -> Int) { }
499+
500+
// Don't crash on this example
501+
@inlinable
502+
public func reproduce(_ e: Something) {
503+
use {
504+
return e.f()
505+
}
506+
}

0 commit comments

Comments
 (0)