@@ -14,7 +14,10 @@ struct GS<Base> {
1414 var _value: Builtin.Int64
1515}
1616
17- class Klass {}
17+ class Klass {
18+ @_hasStorage var i: Int
19+ init()
20+ }
1821
1922struct Two {
2023 var a: Klass
@@ -50,6 +53,7 @@ bb0(%0 : $*Klass, %1 : $*Klass):
5053
5154sil @throwing_function : $@convention(thin) (@in_guaranteed Klass) -> ((), @error Error)
5255sil @use_gsbase_builtinnativeobject : $@convention(thin) (@guaranteed GS<Builtin.NativeObject>) -> ()
56+ sil [readonly] @readonly_throwing_func : $@convention(thin) (@in_guaranteed Int) -> @error Error
5357
5458sil_global @globalString : $String
5559
@@ -976,6 +980,32 @@ bb0(%0 : $*Klass, %1 : @owned $Klass):
976980 return %9999 : $()
977981}
978982
983+ // Just check that we don't crash here.
984+ // Currently this pattern is not optimized, but we might in future.
985+ sil [ossa] @dont_extend_access_scope_over_term_inst : $@convention(thin) (@guaranteed Klass) -> () {
986+ bb0(%0 : @guaranteed $Klass):
987+ %1 = ref_element_addr %0 : $Klass, #Klass.i
988+ %2 = begin_access [read] [dynamic] %1 : $*Int
989+ %3 = alloc_stack $Int
990+ copy_addr %2 to [initialization] %3 : $*Int
991+ end_access %2 : $*Int
992+ %6 = function_ref @readonly_throwing_func : $@convention(thin) (@in_guaranteed Int) -> @error Error
993+ try_apply %6(%3) : $@convention(thin) (@in_guaranteed Int) -> @error Error, normal bb1, error bb2
994+ bb1(%8 : $()):
995+ destroy_addr %3 : $*Int
996+ dealloc_stack %3 : $*Int
997+ br bb3
998+ bb2(%12 : @owned $Error):
999+ destroy_addr %3 : $*Int
1000+ dealloc_stack %3 : $*Int
1001+ destroy_value %12 : $Error
1002+ br bb3
1003+ bb3:
1004+ %17 = tuple ()
1005+ return %17 : $()
1006+ }
1007+
1008+
9791009/////////////////
9801010// Store Tests //
9811011/////////////////
0 commit comments