Skip to content

Commit e22bed2

Browse files
authored
Merge pull request #16488 from slavapestov/fix-resilience-bypass-again
IRGen: Fix enum lowering with -enable-resilience-bypass
2 parents e9c7b1b + 51ece23 commit e22bed2

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

lib/IRGen/GenDecl.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4062,8 +4062,10 @@ IRGenModule::getAddrOfGlobalUTF16ConstantString(StringRef utf8) {
40624062
/// - For classes, the superclass might change the size or number
40634063
/// of stored properties
40644064
bool IRGenModule::isResilient(NominalTypeDecl *D, ResilienceExpansion expansion) {
4065-
if (Types.isCompletelyFragile())
4065+
if (expansion == ResilienceExpansion::Maximal &&
4066+
Types.isCompletelyFragile()) {
40664067
return false;
4068+
}
40674069
return D->isResilient(getSwiftModule(), expansion);
40684070
}
40694071

lib/IRGen/GenEnum.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5145,7 +5145,7 @@ EnumImplStrategy::get(TypeConverter &TC, SILType type, EnumDecl *theEnum) {
51455145
// can reproduce.
51465146
if (!substArgTI->isFixedSize(layoutScope)) {
51475147
alwaysFixedSize = IsNotFixedSize;
5148-
allowFixedLayoutOptimizations = false;
5148+
assert(!allowFixedLayoutOptimizations);
51495149
}
51505150
}
51515151
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
public class C {}
2+
3+
public struct S {
4+
public let c: C
5+
6+
public init() {
7+
self.c = C()
8+
}
9+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import first
2+
3+
public enum E {
4+
case a(S)
5+
case b(S)
6+
}

test/IRGen/resilience_bypass.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/first.swiftmodule -module-name=first %S/Inputs/resilience_bypass/first.swift
4+
// RUN: %target-swift-frontend -emit-module -emit-module-path=%t/second.swiftmodule -module-name=second %S/Inputs/resilience_bypass/second.swift -I %t
5+
// RUN: %target-swift-frontend -emit-ir -enable-resilience-bypass %s -I %t | %FileCheck %s -DINT=i%target-ptrsize
6+
7+
import second
8+
9+
// CHECK: define{{( protected)?}} swiftcc [[INT]] @"$S17resilience_bypass7getSizeSiyF"() {{.*}} {
10+
// CHECK-NEXT: entry:
11+
// CHECK-NEXT: ret [[INT]] {{5|9}}
12+
// CHECK-NEXT: }
13+
14+
public func getSize() -> Int {
15+
return MemoryLayout<E>.size
16+
}

0 commit comments

Comments
 (0)