@@ -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)
@@ -25,6 +29,7 @@ sil [ossa] @takeOwnedCTwice : $@convention(thin) (@owned C, @owned C) -> ()
25
29
sil [ossa] @takeGuaranteedC : $@convention(thin) (@guaranteed C) -> ()
26
30
sil [ossa] @borrowB : $@convention(thin) (@guaranteed B) -> ()
27
31
sil [ossa] @takeGuaranteedAnyObject : $@convention(thin) (@guaranteed AnyObject) -> ()
32
+ sil [ossa] @getMOS : $() -> (@owned MOS)
28
33
29
34
// -O hoists the destroy
30
35
//
@@ -989,3 +994,23 @@ bb0:
989
994
%99 = tuple ()
990
995
return %99 : $()
991
996
}
997
+
998
+ // CHECK-LABEL: sil [ossa] @dontShortenDeadMoveOnlyLifetime : {{.*}} {
999
+ // CHECK: [[GET:%[^,]+]] = function_ref @getMOS
1000
+ // CHECK: [[BARRIER:%[^,]+]] = function_ref @barrier
1001
+ // CHECK: [[MOS:%[^,]+]] = apply [[GET]]()
1002
+ // CHECK: [[MOV:%[^,]+]] = move_value [lexical] [[MOS]]
1003
+ // CHECK: apply [[BARRIER]]()
1004
+ // CHECK: destroy_value [[MOV]]
1005
+ // CHECK-LABEL: } // end sil function 'dontShortenDeadMoveOnlyLifetime'
1006
+ sil [ossa] @dontShortenDeadMoveOnlyLifetime : $@convention(thin) () -> () {
1007
+ %get = function_ref @getMOS : $@convention(thin) () -> (@owned MOS)
1008
+ %barrier = function_ref @barrier : $@convention(thin) () -> ()
1009
+ %mos = apply %get() : $@convention(thin) () -> (@owned MOS)
1010
+ // Note: This must be lexical so that it doesn't get eliminated as redundant.
1011
+ %mov = move_value [lexical] %mos : $MOS
1012
+ apply %barrier() : $@convention(thin) () -> ()
1013
+ destroy_value %mov : $MOS
1014
+ %retval = tuple ()
1015
+ return %retval : $()
1016
+ }
0 commit comments