@@ -44,6 +44,23 @@ unwind:
44
44
unwind
45
45
}
46
46
47
+ sil [ossa] @getSomeClass : $@convention(thin) () -> @owned SomeClass
48
+
49
+ sil [transparent] [ossa] @yield_owned_as_guaranteed : $@yield_once @convention(thin) () -> @yields @guaranteed SomeClass {
50
+ %getSomeClass = function_ref @getSomeClass : $@convention(thin) () -> @owned SomeClass
51
+ %SomeClass = apply %getSomeClass() : $@convention(thin) () -> @owned SomeClass
52
+ yield %SomeClass : $SomeClass, resume bb1, unwind bb2
53
+
54
+ bb1:
55
+ destroy_value %SomeClass : $SomeClass
56
+ %retval = tuple ()
57
+ return %retval : $()
58
+
59
+ bb2:
60
+ destroy_value %SomeClass : $SomeClass
61
+ unwind
62
+ }
63
+
47
64
sil [transparent] [ossa] @test_unreachable : $@yield_once <C: SomeClass> () -> (@yields @in Indirect<C>) {
48
65
entry:
49
66
unreachable
@@ -555,3 +572,48 @@ bb2:
555
572
return %ret : $()
556
573
}
557
574
575
+
576
+ // CHECK-LABEL: sil [ossa] @test_store_borrow_owned_as_guaranteed_yield : {{.*}} {
577
+ // CHECK: {{bb[0-9]+}}:
578
+ // CHECK: [[ADDR:%[^,]+]] = alloc_stack $SomeClass
579
+ // CHECK: [[INSTANCE:%[^,]+]] = apply
580
+ // CHECK: [[LIFETIME:%[^,]+]] = begin_borrow [[INSTANCE]]
581
+ // CHECK: [[BORROW:%[^,]+]] = store_borrow [[LIFETIME]] to [[ADDR]]
582
+ // CHECK: yield [[BORROW]] {{.*}}, resume [[BB_RESUME:bb[0-9]+]], unwind [[BB_UNWIND:bb[0-9]+]]
583
+ // CHECK: [[BB_RESUME]]:
584
+ // CHECK: end_borrow [[BORROW]]
585
+ // CHECK: dealloc_stack [[ADDR]]
586
+ // CHECK: end_borrow [[LIFETIME]]
587
+ // CHECK: destroy_value [[INSTANCE]]
588
+ // CHECK: tuple ()
589
+ // CHECK: [[RETVAL:%[^,]+]] = tuple ()
590
+ // CHECK: return [[RETVAL]]
591
+ // CHECK: [[BB_UNWIND]]:
592
+ // CHECK: end_borrow [[BORROW]]
593
+ // CHECK: dealloc_stack [[ADDR]]
594
+ // CHECK: end_borrow [[LIFETIME]]
595
+ // CHECK: destroy_value [[INSTANCE]]
596
+ // CHECK: unwind
597
+ // CHECK-LABEL: } // end sil function 'test_store_borrow_owned_as_guaranteed_yield'
598
+ sil [ossa] @test_store_borrow_owned_as_guaranteed_yield : $@yield_once @convention(thin) @substituted <T> () -> @yields @in_guaranteed T for <SomeClass> {
599
+ entry:
600
+ %addr = alloc_stack $SomeClass
601
+ %callee = function_ref @yield_owned_as_guaranteed : $@yield_once @convention(thin) () -> @yields @guaranteed SomeClass
602
+ (%instance, %token) = begin_apply %callee() : $@yield_once @convention(thin) () -> @yields @guaranteed SomeClass
603
+ %borrow = store_borrow %instance to %addr : $*SomeClass
604
+ yield %borrow : $*SomeClass, resume bb_resume, unwind bb_unwind
605
+
606
+ bb_resume:
607
+ end_borrow %borrow : $*SomeClass
608
+ dealloc_stack %addr : $*SomeClass
609
+ end_apply %token
610
+ %retval = tuple ()
611
+ return %retval : $()
612
+
613
+ bb_unwind:
614
+ end_borrow %borrow : $*SomeClass
615
+ dealloc_stack %addr : $*SomeClass
616
+ abort_apply %token
617
+ unwind
618
+
619
+ }
0 commit comments