@@ -16,6 +16,10 @@ class C {
16
16
var a: Builtin.Int64
17
17
}
18
18
19
+ struct MOS : ~Copyable {
20
+ deinit {}
21
+ }
22
+
19
23
sil [ossa] @dummy : $@convention(thin) () -> ()
20
24
sil [ossa] @barrier : $@convention(thin) () -> ()
21
25
sil [ossa] @getOwnedC : $@convention(thin) () -> (@owned C)
@@ -26,6 +30,7 @@ sil [ossa] @takeOwnedCAndGuaranteedC : $@convention(thin) (@owned C, @guaranteed
26
30
sil [ossa] @takeGuaranteedC : $@convention(thin) (@guaranteed C) -> ()
27
31
sil [ossa] @borrowB : $@convention(thin) (@guaranteed B) -> ()
28
32
sil [ossa] @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
33
+ sil [ossa] @getMOS : $() -> (@owned MOS)
29
34
30
35
// -O hoists the destroy
31
36
//
@@ -1047,3 +1052,23 @@ entry(%instance : @owned $C):
1047
1052
%retval = tuple ()
1048
1053
return %retval : $()
1049
1054
}
1055
+
1056
+ // CHECK-LABEL: sil [ossa] @dontShortenDeadMoveOnlyLifetime : {{.*}} {
1057
+ // CHECK: [[GET:%[^,]+]] = function_ref @getMOS
1058
+ // CHECK: [[BARRIER:%[^,]+]] = function_ref @barrier
1059
+ // CHECK: [[MOS:%[^,]+]] = apply [[GET]]()
1060
+ // CHECK: [[MOV:%[^,]+]] = move_value [lexical] [[MOS]]
1061
+ // CHECK: apply [[BARRIER]]()
1062
+ // CHECK: destroy_value [[MOV]]
1063
+ // CHECK-LABEL: } // end sil function 'dontShortenDeadMoveOnlyLifetime'
1064
+ sil [ossa] @dontShortenDeadMoveOnlyLifetime : $@convention(thin) () -> () {
1065
+ %get = function_ref @getMOS : $@convention(thin) () -> (@owned MOS)
1066
+ %barrier = function_ref @barrier : $@convention(thin) () -> ()
1067
+ %mos = apply %get() : $@convention(thin) () -> (@owned MOS)
1068
+ // Note: This must be lexical so that it doesn't get eliminated as redundant.
1069
+ %mov = move_value [lexical] %mos : $MOS
1070
+ apply %barrier() : $@convention(thin) () -> ()
1071
+ destroy_value %mov : $MOS
1072
+ %retval = tuple ()
1073
+ return %retval : $()
1074
+ }
0 commit comments