Skip to content

Commit 6f4c5c4

Browse files
committed
IRGen: Correctly compute fixed sized'ness of resilient enums
rdar://51422528
1 parent a868cfb commit 6f4c5c4

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

lib/IRGen/GenEnum.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5794,7 +5794,9 @@ std::unique_ptr<EnumImplStrategy>
57945794
EnumImplStrategy::get(TypeConverter &TC, SILType type, EnumDecl *theEnum) {
57955795
unsigned numElements = 0;
57965796
TypeInfoKind tik = Loadable;
5797-
IsFixedSize_t alwaysFixedSize = IsFixedSize;
5797+
IsFixedSize_t alwaysFixedSize =
5798+
TC.IGM.isResilient(theEnum, ResilienceExpansion::Minimal) ? IsNotFixedSize
5799+
: IsFixedSize;
57985800
bool allowFixedLayoutOptimizations = true;
57995801
std::vector<Element> elementsWithPayload;
58005802
std::vector<Element> elementsWithNoPayload;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public enum ResilientType {
2+
case a(Int64)
3+
case b(Int64)
4+
}
5+
6+
@frozen
7+
public enum SomeEnum {
8+
case first(ResilientType)
9+
case second(ResilientType)
10+
}

test/multifile/resilient-module.swift

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-build-swift-dylib(%t/%target-library-name(A)) -enable-library-evolution -module-name A -emit-module -emit-module-path %t/A.swiftmodule %S/Inputs/resilient-module-2.swift
3+
// RUN: %target-swift-frontend -target x86_64-apple-macosx10.14 -enable-library-evolution -module-name A %S/Inputs/resilient-module-2.swift -emit-ir | %FileCheck --check-prefix=METADATA %s
4+
// RUN: %target-build-swift -I%t -L%t -lA -o %t/main %target-rpath(%t) %s
5+
// RUN: %target-build-swift -I%t -L%t -lA -o %t/main %target-rpath(%t) %s
6+
// RUN: %target-codesign %t/main %t/%target-library-name(A)
7+
// RUN: %target-run %t/main %t/%target-library-name(A) | %FileCheck %s
8+
9+
10+
// METADATA: @"$s1A8SomeEnumOMn" = constant <{ i32, i32, i32, i32, i32, i32, i32 }> <{{{.*}} i32 33554434, i32 0 }>
11+
12+
import A
13+
14+
func runTest() {
15+
let e = SomeEnum.first(ResilientType.a(Int64(10)))
16+
// CHECK: first(A.ResilientType.a(10))
17+
print(e)
18+
}
19+
20+
runTest()

0 commit comments

Comments
 (0)