@@ -254,3 +254,59 @@ bb3:
254254 return %2 : $C
255255}
256256
257+ // CHECK-LABEL: sil [ossa] @test_store_borrow :
258+ // CHECK: bb1:
259+ // CHECK-NEXT: end_borrow
260+ // CHECK-NEXT: end_init_let_ref %2
261+ // CHECK: bb2:
262+ // CHECK: end_borrow {{%[0-9]}} : $*C
263+ // CHECK: [[B:%.*]] = begin_borrow %2
264+ // CHECK: end_borrow [[B]] : $C
265+ // CHECK-NEXT: end_init_let_ref %2
266+ // CHECK: } // end sil function 'test_store_borrow'
267+ sil [ossa] @test_store_borrow : $@convention(thin) (@owned C, Int) -> @owned C {
268+ bb0(%0 : @owned $C, %1 : $Int):
269+ %2 = mark_uninitialized [rootself] %0 : $C
270+ %3 = begin_borrow %2 : $C
271+ %4 = ref_element_addr %3 : $C, #C.a
272+ store %1 to [trivial] %4 : $*Int
273+ end_borrow %3 : $C
274+ %10 = alloc_stack $C
275+ %11 = store_borrow %2 to %10 : $*C
276+ cond_br undef, bb1, bb2
277+ bb1:
278+ end_borrow %11 : $*C
279+ dealloc_stack %10 : $*C
280+ return %2 : $C
281+ bb2:
282+ end_borrow %11 : $*C
283+ %17 = begin_borrow %2 : $C
284+ %18 = ref_element_addr %17 : $C, #C.a
285+ %19 = begin_access [deinit] [static] %18 : $*Int
286+ destroy_addr %19 : $*Int
287+ end_access %19 : $*Int
288+ end_borrow %17 : $C
289+ unreachable
290+ }
291+
292+ // CHECK-LABEL: sil [ossa] @test_reborrow :
293+ // CHECK: bb1([[A:%.*]] : @reborrow @guaranteed $C):
294+ // CHECK: end_borrow [[A]]
295+ // CHECK-NEXT: end_init_let_ref %2
296+ // CHECK: } // end sil function 'test_reborrow'
297+ sil [ossa] @test_reborrow : $@convention(thin) (@owned C, Int) -> @owned C {
298+ bb0(%0 : @owned $C, %1 : $Int):
299+ %2 = mark_uninitialized [rootself] %0 : $C
300+ %3 = begin_borrow %2 : $C
301+ %4 = ref_element_addr %3 : $C, #C.a
302+ store %1 to [trivial] %4 : $*Int
303+ br bb1(%3 : $C)
304+ bb1(%3a : @reborrow @guaranteed $C):
305+ end_borrow %3a : $C
306+ %7 = begin_borrow %2 : $C
307+ %8 = ref_element_addr %7 : $C, #C.a
308+ %9 = load [trivial] %8 : $*Int
309+ end_borrow %7 : $C
310+ return %2 : $C
311+ }
312+
0 commit comments