@@ -45,7 +45,6 @@ struct NE: ~Escapable {
45
45
46
46
sil [ossa] @useCAddress : $@convention(thin) (@inout_aliasable C) -> ()
47
47
48
-
49
48
// =============================================================================
50
49
// LinearLiveness
51
50
// =============================================================================
@@ -2139,3 +2138,96 @@ exit:
2139
2138
%retval = tuple ()
2140
2139
return %retval : $()
2141
2140
}
2141
+
2142
+ class Klass {
2143
+ }
2144
+
2145
+ public struct Wrapper {
2146
+ var _k: Klass
2147
+ var i: Int
2148
+ }
2149
+
2150
+ sil @get_wrapper : $@convention(thin) () -> @owned Wrapper
2151
+ sil @use_klass : $@convention(thin) (@guaranteed Klass) -> ()
2152
+
2153
+ sil [ossa] @borrow_loadable_prop : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass {
2154
+ bb0(%0 : @guaranteed $Wrapper):
2155
+ %2 = struct_extract %0, #Wrapper._k
2156
+ return %2
2157
+ }
2158
+
2159
+ // CHECK: begin running test 1 of 2 on test_borrow_accessor1: interior_liveness with: %1
2160
+ // CHECK: sil [ossa] @test_borrow_accessor1 : $@convention(thin) (@owned Wrapper) -> () {
2161
+ // CHECK: bb0(%0 : @owned $Wrapper):
2162
+ // CHECK: %1 = copy_value %0 : $Wrapper
2163
+ // CHECK: %2 = begin_borrow %1 : $Wrapper
2164
+ // CHECK: %3 = function_ref @borrow_loadable_prop : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass
2165
+ // CHECK: %4 = apply %3(%2) : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass
2166
+ // CHECK: %5 = function_ref @use_klass : $@convention(thin) (@guaranteed Klass) -> ()
2167
+ // CHECK: %6 = apply %5(%4) : $@convention(thin) (@guaranteed Klass) -> ()
2168
+ // CHECK: unreachable
2169
+ // CHECK: }
2170
+ // CHECK: Interior liveness: %2 = begin_borrow %1 : $Wrapper
2171
+ // CHECK: bb0: LiveWithin
2172
+ // CHECK: regular user: %4 = apply %3(%2) : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass
2173
+ // CHECK: regular user: %6 = apply %5(%4) : $@convention(thin) (@guaranteed Klass) -> ()
2174
+ // CHECK: Complete liveness
2175
+ // CHECK: last user: %6 = apply %5(%4) : $@convention(thin) (@guaranteed Klass) -> ()
2176
+ // CHECK: end running test 1 of 2 on test_borrow_accessor1: interior_liveness with: %1
2177
+ sil [ossa] @test_borrow_accessor1 : $@convention(thin) (@owned Wrapper) -> () {
2178
+ bb0(%0 : @owned $Wrapper):
2179
+ specify_test "interior_liveness %1"
2180
+ specify_test "interior_liveness_swift %1"
2181
+ %copy = copy_value %0
2182
+ %1 = begin_borrow %copy
2183
+ %2 = function_ref @borrow_loadable_prop : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass
2184
+ %3 = apply %2(%1) : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass
2185
+ %4 = function_ref @use_klass : $@convention(thin) (@guaranteed Klass) -> ()
2186
+ %5 = apply %4(%3) : $@convention(thin) (@guaranteed Klass) -> ()
2187
+ unreachable
2188
+ }
2189
+
2190
+ // CHECK: begin running test 1 of 2 on test_borrow_accessor2: interior_liveness with: %3
2191
+ // CHECK: sil [ossa] @test_borrow_accessor2 : $@convention(thin) () -> () {
2192
+ // CHECK: bb0:
2193
+ // CHECK: %0 = function_ref @get_wrapper : $@convention(thin) () -> @owned Wrapper
2194
+ // CHECK: %1 = apply %0() : $@convention(thin) () -> @owned Wrapper
2195
+ // CHECK: %2 = begin_borrow %1 : $Wrapper
2196
+ // CHECK: %3 = function_ref @borrow_loadable_prop : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass
2197
+ // CHECK: %4 = apply %3(%2) : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass
2198
+ // CHECK: %5 = copy_value %4 : $Klass
2199
+ // CHECK: %6 = function_ref @use_klass : $@convention(thin) (@guaranteed Klass) -> ()
2200
+ // CHECK: %7 = apply %6(%5) : $@convention(thin) (@guaranteed Klass) -> ()
2201
+ // CHECK: unreachable
2202
+ // CHECK: }
2203
+ // CHECK: Interior liveness: %2 = begin_borrow %1 : $Wrapper
2204
+ // CHECK: bb0: LiveWithin
2205
+ // CHECK: regular user: %4 = apply %3(%2) : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass
2206
+ // CHECK: regular user: %5 = copy_value %4 : $Klass
2207
+ // CHECK: Complete liveness
2208
+ // CHECK: last user: %5 = copy_value %4 : $Klass
2209
+ // CHECK: end running test 1 of 2 on test_borrow_accessor2: interior_liveness with: %3
2210
+ // CHECK: begin running test 2 of 2 on test_borrow_accessor2: interior_liveness_swift with: %3
2211
+ // CHECK: Interior liveness: %2 = begin_borrow %1 : $Wrapper
2212
+ // CHECK: begin: %2 = begin_borrow %1 : $Wrapper
2213
+ // CHECK: ends: %5 = copy_value %4 : $Klass
2214
+ // CHECK: exits:
2215
+ // CHECK: interiors: %4 = apply %3(%2) : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass
2216
+ // CHECK: last user: %5 = copy_value %4 : $Klass
2217
+ // CHECK: end running test 2 of 2 on test_borrow_accessor2: interior_liveness_swift with: %3
2218
+
2219
+ sil [ossa] @test_borrow_accessor2 : $@convention(thin) () -> () {
2220
+ bb0:
2221
+ specify_test "interior_liveness %3"
2222
+ specify_test "interior_liveness_swift %3"
2223
+ %1 = function_ref @get_wrapper : $@convention(thin) () -> @owned Wrapper
2224
+ %2 = apply %1() : $@convention(thin) () -> @owned Wrapper
2225
+ %3 = begin_borrow %2
2226
+ %4 = function_ref @borrow_loadable_prop : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass
2227
+ %5 = apply %4(%3) : $@convention(method) (@guaranteed Wrapper) -> @guaranteed Klass
2228
+ %copy = copy_value %5
2229
+ %6 = function_ref @use_klass : $@convention(thin) (@guaranteed Klass) -> ()
2230
+ %7 = apply %6(%copy) : $@convention(thin) (@guaranteed Klass) -> ()
2231
+ unreachable
2232
+ }
2233
+
0 commit comments