Skip to content

Commit c039b4a

Browse files
Merge pull request #25759 from aschwaighofer/irgen_resilient_non_resilient_same_module-5.1
[5.1] IRGen: Correctly compute fixed sized'ness of resilient enums
2 parents 16859f1 + 6919f51 commit c039b4a

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

lib/IRGen/GenEnum.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5812,6 +5812,9 @@ EnumImplStrategy::get(TypeConverter &TC, SILType type, EnumDecl *theEnum) {
58125812
std::vector<Element> elementsWithPayload;
58135813
std::vector<Element> elementsWithNoPayload;
58145814

5815+
if (TC.IGM.isResilient(theEnum, ResilienceExpansion::Minimal))
5816+
alwaysFixedSize = IsNotFixedSize;
5817+
58155818
// Resilient enums are manipulated as opaque values, except we still
58165819
// make the following assumptions:
58175820
// 1) The indirect-ness of cases won't change
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 -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)