@@ -36,6 +36,7 @@ sil [ossa] @callee_optional_d_guaranteed: $@convention(thin) (@guaranteed Option
36
36
sil [ossa] @synchronization_point : $@convention(thin) () -> ()
37
37
sil [ossa] @modify_s : $@yield_once @convention(thin) () -> @yields @inout S
38
38
sil [ossa] @barrier : $@convention(thin) () -> ()
39
+ sil [ossa] @failable : $@convention(thin) () -> @error Error
39
40
40
41
41
42
// =============================================================================
@@ -888,7 +889,7 @@ exit:
888
889
889
890
// Don't hoist over end_apply. These are lowered to calls to continuations
890
891
// which can have the same sorts of side-effects as function calls.
891
-
892
+ //
892
893
// CHECK-LABEL: sil [ossa] @dont_hoist_over_end_apply : {{.*}} {
893
894
// CHECK: end_apply
894
895
// CHECK: end_borrow
@@ -906,6 +907,40 @@ entry(%instance : @owned $C, %input : $S):
906
907
return %retval : $()
907
908
}
908
909
910
+ // Don't hoist over abort_apply. These are lowered to calls to continuations
911
+ // which can have the same sorts of side-effects as function calls.
912
+ //
913
+ // CHECK-LABEL: sil [ossa] @dont_hoist_over_abort_apply : {{.*}} {
914
+ // CHECK: {{bb[0-9]+}}([[REGISTER_1:%[^,]+]] : $Error):
915
+ // CHECK: abort_apply
916
+ // CHECK: end_borrow
917
+ // CHECK: destroy_value
918
+ // CHECK: tuple
919
+ // CHECK: throw
920
+ // CHECK-LABEL: } // end sil function 'dont_hoist_over_abort_apply'
921
+ sil [ossa] @dont_hoist_over_abort_apply : $@convention(thin) (@owned C, S) -> @error Error {
922
+ entry(%instance : @owned $C, %input : $S):
923
+ %lifetime = begin_borrow [lexical] %instance : $C
924
+ %callee_guaranteed = function_ref @callee_guaranteed : $@convention(thin) (@guaranteed C) -> ()
925
+ apply %callee_guaranteed(%lifetime) : $@convention(thin) (@guaranteed C) -> ()
926
+ %modify_s = function_ref @modify_s : $@yield_once @convention(thin) () -> @yields @inout S
927
+ (%addr, %continuation) = begin_apply %modify_s() : $@yield_once @convention(thin) () -> @yields @inout S
928
+ %failable = function_ref @failable : $@convention(thin) () -> @error Error
929
+ try_apply %failable() : $@convention(thin) () -> @error Error, normal success, error failure
930
+ success(%retval : $()):
931
+ store %input to [trivial] %addr : $*S
932
+ end_apply %continuation
933
+ end_borrow %lifetime : $C
934
+ destroy_value %instance : $C
935
+ return %retval : $()
936
+ failure(%error : $Error):
937
+ abort_apply %continuation
938
+ %blah = tuple ()
939
+ end_borrow %lifetime : $C
940
+ destroy_value %instance : $C
941
+ throw %error : $Error
942
+ }
943
+
909
944
// Don't hoist out of a block when one of its predecessors has a terminator that
910
945
// is a use of the end_borrow.
911
946
//
0 commit comments