@@ -11,6 +11,7 @@ class C {
11
11
weak var d: D?
12
12
}
13
13
class D {}
14
+ struct S {}
14
15
class DBox {
15
16
var d: D
16
17
}
@@ -32,6 +33,7 @@ sil [ossa] @callee_guaranteed: $@convention(thin) (@guaranteed C) -> ()
32
33
sil [ossa] @callee_owned : $@convention(thin) (@owned C) -> ()
33
34
sil [ossa] @callee_optional_d_guaranteed: $@convention(thin) (@guaranteed Optional<D>) -> ()
34
35
sil [ossa] @synchronization_point : $@convention(thin) () -> ()
36
+ sil [ossa] @modify_s : $@yield_once @convention(thin) () -> @yields @inout S
35
37
36
38
// =============================================================================
37
39
// = DECLARATIONS }}
@@ -807,6 +809,27 @@ exit:
807
809
return %retval : $()
808
810
}
809
811
812
+ // Don't hoist over end_apply. These are lowered to calls to continuations
813
+ // which can have the same sorts of side-effects as function calls.
814
+
815
+ // CHECK-LABEL: sil [ossa] @dont_hoist_over_end_apply : {{.*}} {
816
+ // CHECK: end_apply
817
+ // CHECK: end_borrow
818
+ // CHECK-LABEL: } // end sil function 'dont_hoist_over_end_apply'
819
+ sil [ossa] @dont_hoist_over_end_apply : $@convention(thin) (@owned C, S) -> () {
820
+ entry(%instance : @owned $C, %input : $S):
821
+ %lifetime = begin_borrow [lexical] %instance : $C
822
+ %modify_s = function_ref @modify_s : $@yield_once @convention(thin) () -> @yields @inout S
823
+ (%addr, %continuation) = begin_apply %modify_s() : $@yield_once @convention(thin) () -> @yields @inout S
824
+ store %input to [trivial] %addr : $*S
825
+ end_apply %continuation
826
+ end_borrow %lifetime : $C
827
+ destroy_value %instance : $C
828
+ %retval = tuple ()
829
+ return %retval : $()
830
+ }
831
+
832
+
810
833
// =============================================================================
811
834
// instruction tests }}
812
835
// =============================================================================
0 commit comments