@@ -63,6 +63,11 @@ public class KlassBar : KlassFoo {
63
63
init()
64
64
}
65
65
66
+ indirect public enum IndirectEnum : Hashable {
67
+ case A
68
+ case B(IndirectEnum)
69
+ }
70
+
66
71
sil @use_Int : $@convention(thin) (Int) -> ()
67
72
sil @use_Int64 : $@convention(thin) (Int64) -> ()
68
73
sil @use_Generic : $@convention(thin) <T>(@in_guaranteed T) -> ()
@@ -514,6 +519,39 @@ bb0(%0 : $boo):
514
519
return %0 : $boo
515
520
}
516
521
522
+ // CHECK-LABEL: sil @no_fso_recursive_result_is_not_returned :
523
+ // CHECK-NOT: release_value
524
+ // CHECK: bb2:
525
+ // CHECK-NEXT: retain_value %0
526
+ // CHECK: return
527
+ // CHECK-LABEL: } // end sil function 'no_fso_recursive_result_is_not_returned'
528
+ sil @no_fso_recursive_result_is_not_returned : $@convention(method) (@guaranteed IndirectEnum, @guaranteed IndirectEnum) -> @owned IndirectEnum {
529
+ bb0(%0 : $IndirectEnum, %1 : $IndirectEnum):
530
+ switch_enum %1 : $IndirectEnum, case #IndirectEnum.B!enumelt: bb1, default bb2
531
+
532
+ bb1(%3 : ${ var IndirectEnum }):
533
+ %4 = project_box %3 : ${ var IndirectEnum }, 0
534
+ %5 = load %4 : $*IndirectEnum
535
+ %6 = function_ref @no_fso_recursive_result_is_not_returned : $@convention(method) (@guaranteed IndirectEnum, @guaranteed IndirectEnum) -> @owned IndirectEnum
536
+
537
+ // The result of the self-recursion is not returned (but put in a box).
538
+ // This prevents guaranteed -> owned return value specialization.
539
+ %7 = apply %6(%0, %5) : $@convention(method) (@guaranteed IndirectEnum, @guaranteed IndirectEnum) -> @owned IndirectEnum
540
+ %8 = alloc_box ${ var IndirectEnum }
541
+ %9 = project_box %8 : ${ var IndirectEnum }, 0
542
+ store %7 to %9 : $*IndirectEnum
543
+ %11 = enum $IndirectEnum, #IndirectEnum.B!enumelt, %8 : ${ var IndirectEnum }
544
+ br bb3(%11 : $IndirectEnum)
545
+
546
+ bb2:
547
+ retain_value %0 : $IndirectEnum
548
+ br bb3(%0 : $IndirectEnum)
549
+
550
+ bb3(%35 : $IndirectEnum):
551
+ return %35 : $IndirectEnum
552
+ }
553
+
554
+
517
555
// Make sure we do not move the retain_value in the throw block.
518
556
//
519
557
// CHECK-LABEL: sil [serialized] [signature_optimized_thunk] [always_inline] @owned_to_unowned_retval_with_error_result : $@convention(thin) (@owned boo) -> (@owned boo, @error Error) {
0 commit comments