@@ -10,6 +10,11 @@ class C {
10
10
init(i: Builtin.Int64)
11
11
}
12
12
13
+ private class C2 {
14
+ var i: Builtin.Int64 { get set }
15
+ init(i: Builtin.Int64)
16
+ }
17
+
13
18
class Klass {}
14
19
15
20
sil [transparent] [ossa] @calleeWithGuaranteed : $@convention(thin) (@guaranteed C) -> Builtin.Int64 {
@@ -501,3 +506,81 @@ bb3:
501
506
return %19 : $()
502
507
}
503
508
509
+ sil [ossa] [transparent] @devirt_callee : $@yield_once @convention(method) (@guaranteed C) -> @yields @inout Builtin.Int64 {
510
+ bb0(%0 : @guaranteed $C):
511
+ %1 = alloc_stack $Builtin.Int64
512
+ %1a = integer_literal $Builtin.Int64, 0
513
+ store %1a to [trivial] %1 : $*Builtin.Int64
514
+ yield %1 : $*Builtin.Int64, resume bb1, unwind bb2
515
+
516
+ bb1:
517
+ dealloc_stack %1 : $*Builtin.Int64
518
+ %6 = tuple ()
519
+ return %6 : $()
520
+
521
+ bb2:
522
+ dealloc_stack %1 : $*Builtin.Int64
523
+ unwind
524
+ }
525
+
526
+ // Just make sure we actually inlined the begin_apply. We just want to make sure
527
+ // we are not breaking ownership invariants by not properly borrowing %0.
528
+ // CHECK-LABEL: sil [ossa] @begin_apply_devirt_caller : $@convention(method) (@owned C2) -> @error Error {
529
+ // CHECK-NOT: begin_apply
530
+ // CHECK: } // end sil function 'begin_apply_devirt_caller'
531
+ sil [ossa] @begin_apply_devirt_caller : $@convention(method) (@owned C2) -> @error Error {
532
+ bb0(%0 : @owned $C2):
533
+ %1 = class_method %0 : $C2, #C2.i!modify.1 : (C2) -> () -> (), $@yield_once @convention(method) (@guaranteed C2) -> @yields @inout Builtin.Int64
534
+ (%mem, %tok) = begin_apply %1(%0) : $@yield_once @convention(method) (@guaranteed C2) -> @yields @inout Builtin.Int64
535
+ br bb1
536
+
537
+ bb1:
538
+ end_apply %tok
539
+ destroy_value %0 : $C2
540
+ %9999 = tuple()
541
+ return %9999 : $()
542
+ }
543
+
544
+ // CHECK-LABEL: sil [ossa] @begin_apply_devirt_caller_2 : $@convention(method) (@owned C2) -> @error Error {
545
+ // CHECK-NOT: begin_apply
546
+ // CHECK: } // end sil function 'begin_apply_devirt_caller_2'
547
+ sil [ossa] @begin_apply_devirt_caller_2 : $@convention(method) (@owned C2) -> @error Error {
548
+ bb0(%0 : @owned $C2):
549
+ %1 = class_method %0 : $C2, #C2.i!modify.1 : (C2) -> () -> (), $@yield_once @convention(method) (@guaranteed C2) -> @yields @inout Builtin.Int64
550
+ (%mem, %tok) = begin_apply %1(%0) : $@yield_once @convention(method) (@guaranteed C2) -> @yields @inout Builtin.Int64
551
+ br bb1
552
+
553
+ bb1:
554
+ abort_apply %tok
555
+ destroy_value %0 : $C2
556
+ %9999 = tuple()
557
+ return %9999 : $()
558
+ }
559
+
560
+ // CHECK-LABEL: sil [ossa] @begin_apply_devirt_caller_3 : $@convention(method) (@owned C2) -> @error Error {
561
+ // CHECK-NOT: begin_apply
562
+ // CHECK: } // end sil function 'begin_apply_devirt_caller_3'
563
+ sil [ossa] @begin_apply_devirt_caller_3 : $@convention(method) (@owned C2) -> @error Error {
564
+ bb0(%0 : @owned $C2):
565
+ %1 = class_method %0 : $C2, #C2.i!modify.1 : (C2) -> () -> (), $@yield_once @convention(method) (@guaranteed C2) -> @yields @inout Builtin.Int64
566
+ (%mem, %tok) = begin_apply %1(%0) : $@yield_once @convention(method) (@guaranteed C2) -> @yields @inout Builtin.Int64
567
+ cond_br undef, bb1, bb2
568
+
569
+ bb1:
570
+ end_apply %tok
571
+ br bb3
572
+
573
+ bb2:
574
+ abort_apply %tok
575
+ br bb3
576
+
577
+ bb3:
578
+ destroy_value %0 : $C2
579
+ %9999 = tuple()
580
+ return %9999 : $()
581
+ }
582
+
583
+
584
+ sil_vtable C2 {
585
+ #C2.i!modify.1: (C2) -> () -> () : @devirt_callee
586
+ }
0 commit comments