Skip to content

Commit 01e0d3f

Browse files
Merge pull request #34311 from aschwaighofer/fix_irgen_fixlifetime_enums
IRGen: Fix fixLifetime emission of enums
2 parents 5cebe1b + 1c85d20 commit 01e0d3f

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

lib/IRGen/GenEnum.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,8 +2716,8 @@ namespace {
27162716
// Unpack as an instance of the payload type and use its fixLifetime
27172717
// operation.
27182718
Explosion srcAsPayload;
2719-
unpackIntoPayloadExplosion(IGF, srcAsPayload, srcAsPayload);
2720-
payloadTI.fixLifetime(IGF, src);
2719+
unpackIntoPayloadExplosion(IGF, src, srcAsPayload);
2720+
payloadTI.fixLifetime(IGF, srcAsPayload);
27212721
return;
27222722
}
27232723
}

test/IRGen/fixlifetime.sil

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,19 @@
88
// unnecessary.
99
// ONONE-NOT: @__swift_fixLifetime
1010

11-
// CHECK-objc-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @test(%T11fixlifetime1CC* %0, %objc_object* %1, i8** %2, i8* %3, %swift.refcounted* %4, %T11fixlifetime3AggV* noalias nocapture dereferenceable({{.*}}) %5) {{.*}} {
11+
// CHECK-objc-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @test(%T11fixlifetime1CC* %0, %objc_object* %1, i8** %2, i8* %3, %swift.refcounted* %4, %T11fixlifetime3AggV* noalias nocapture dereferenceable({{.*}}) %5, {{(i64|i32)}} %6, {{(i64|i32)}} %7) {{.*}} {
1212
// CHECK-objc: entry:
1313
// CHECK-objc: call void bitcast (void (%swift.refcounted*)* @__swift_fixLifetime to void (%T11fixlifetime1CC*)*)(%T11fixlifetime1CC*
1414
// CHECK-objc: call void bitcast (void (%swift.refcounted*)* @__swift_fixLifetime to void (%objc_object*)*)(%objc_object*
1515
// CHECK-objc: call void @__swift_fixLifetime(%swift.refcounted*
1616
// CHECK-objc: call void bitcast (void (%swift.refcounted*)* @__swift_fixLifetime to void (%T11fixlifetime1CC*)*)(%T11fixlifetime1CC*
1717
// CHECK-objc: call void bitcast (void (%swift.refcounted*)* @__swift_fixLifetime to void (%objc_object*)*)(%objc_object*
1818
// CHECK-objc: call void @__swift_fixLifetime(%swift.refcounted*
19+
// CHECK-objc: [[TEMP:%.*]] = inttoptr {{(i64|i32)}} %6 to %objc_object*
20+
// CHECK-objc: call void bitcast (void (%swift.refcounted*)* @__swift_fixLifetime to void (%objc_object*)*)(%objc_object* [[TEMP]])
1921
// CHECK-objc: call void bitcast (void (%swift.refcounted*)* @__swift_fixLifetime to void (%T11fixlifetime1CC**)*)(%T11fixlifetime1CC**
2022

21-
// CHECK-native-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @test(%T11fixlifetime1CC* %0, %swift.refcounted* %1, i8** %2, i8* %3, %swift.refcounted* %4, %T11fixlifetime3AggV* noalias nocapture dereferenceable({{.*}}) %5) {{.*}} {
23+
// CHECK-native-LABEL: define{{( dllexport)?}}{{( protected)?}} swiftcc void @test(%T11fixlifetime1CC* %0, %swift.refcounted* %1, i8** %2, i8* %3, %swift.refcounted* %4, %T11fixlifetime3AggV* noalias nocapture dereferenceable({{.*}}) %5, {{(i64|i32)}} %6, {{(i64|i32)}} %7) {{.*}} {
2224
// CHECK-native: entry:
2325
// CHECK-native: call void bitcast (void (%swift.refcounted*)* @__swift_fixLifetime to void (%T11fixlifetime1CC*)*)(%T11fixlifetime1CC*
2426
// CHECK-native: call void @__swift_fixLifetime(%swift.refcounted*
@@ -44,17 +46,23 @@ struct Agg {
4446
var f : F
4547
}
4648

49+
enum MyOptional<T> {
50+
case none
51+
case some(T)
52+
}
53+
4754
sil [Onone] @test
48-
: $@convention(thin) (C, P, @callee_owned () -> (), Agg) -> () {
49-
bb0(%0 : $C, %1 : $P, %2 : $@callee_owned () -> (), %3 : $Agg):
55+
: $@convention(thin) (C, P, @callee_owned () -> (), Agg, @guaranteed MyOptional<P>) -> () {
56+
bb0(%0 : $C, %1 : $P, %2 : $@callee_owned () -> (), %3 : $Agg, %4 : $MyOptional<P>):
5057
fix_lifetime %0 : $C
5158
fix_lifetime %1 : $P
5259
fix_lifetime %2 : $@callee_owned () -> ()
5360
fix_lifetime %3 : $Agg
61+
fix_lifetime %4 : $MyOptional<P>
5462

55-
%4 = alloc_stack $C
56-
fix_lifetime %4 : $*C
57-
dealloc_stack %4 : $*C
63+
%5 = alloc_stack $C
64+
fix_lifetime %5 : $*C
65+
dealloc_stack %5 : $*C
5866
%9999 = tuple()
5967
return %9999 : $()
6068
}

0 commit comments

Comments
 (0)