diff --git a/lib/IRGen/GenDecl.cpp b/lib/IRGen/GenDecl.cpp index 13da1237d3867..81c674f79f44b 100644 --- a/lib/IRGen/GenDecl.cpp +++ b/lib/IRGen/GenDecl.cpp @@ -4067,8 +4067,10 @@ IRGenModule::getAddrOfGlobalUTF16ConstantString(StringRef utf8) { /// - For classes, the superclass might change the size or number /// of stored properties bool IRGenModule::isResilient(NominalTypeDecl *D, ResilienceExpansion expansion) { - if (Types.isCompletelyFragile()) + if (expansion == ResilienceExpansion::Maximal && + Types.isCompletelyFragile()) { return false; + } return D->isResilient(getSwiftModule(), expansion); } diff --git a/test/IRGen/Inputs/resilience_bypass/first.swift b/test/IRGen/Inputs/resilience_bypass/first.swift new file mode 100644 index 0000000000000..8f9771e50def1 --- /dev/null +++ b/test/IRGen/Inputs/resilience_bypass/first.swift @@ -0,0 +1,9 @@ +public class C {} + +public struct S { + public let c: C + + public init() { + self.c = C() + } +} diff --git a/test/IRGen/Inputs/resilience_bypass/second.swift b/test/IRGen/Inputs/resilience_bypass/second.swift new file mode 100644 index 0000000000000..019596bfafe5d --- /dev/null +++ b/test/IRGen/Inputs/resilience_bypass/second.swift @@ -0,0 +1,6 @@ +import first + +public enum E { + case a(S) + case b(S) +} diff --git a/test/IRGen/resilience_bypass.swift b/test/IRGen/resilience_bypass.swift new file mode 100644 index 0000000000000..95b59e292e800 --- /dev/null +++ b/test/IRGen/resilience_bypass.swift @@ -0,0 +1,16 @@ +// RUN: %empty-directory(%t) + +// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/first.swiftmodule -module-name=first %S/Inputs/resilience_bypass/first.swift +// RUN: %target-swift-frontend -emit-module -emit-module-path=%t/second.swiftmodule -module-name=second %S/Inputs/resilience_bypass/second.swift -I %t +// RUN: %target-swift-frontend -emit-ir -enable-resilience-bypass %s -I %t | %FileCheck %s -DINT=i%target-ptrsize + +import second + +// CHECK: define{{( protected)?}} swiftcc [[INT]] @"$S17resilience_bypass7getSizeSiyF"() {{.*}} { +// CHECK-NEXT: entry: +// CHECK-NEXT: ret [[INT]] {{5|9}} +// CHECK-NEXT: } + +public func getSize() -> Int { + return MemoryLayout.size +}