@@ -79,6 +79,16 @@ class SubclassLet: ClassLet {}
79
79
sil_global [let] @a_let_global : $Klass
80
80
sil_global @a_var_global : $Klass
81
81
82
+ enum EnumWithIndirectCase {
83
+ case first
84
+ indirect case second(Builtin.NativeObject)
85
+ }
86
+
87
+ struct StructWithEnumWithIndirectCaseField {
88
+ var i: Builtin.Int23
89
+ var field : EnumWithIndirectCase
90
+ }
91
+
82
92
///////////
83
93
// Tests //
84
94
///////////
@@ -2727,3 +2737,72 @@ bbEnd:
2727
2737
return %9999 : $()
2728
2738
}
2729
2739
2740
+ // CHECK-LABEL: sil [ossa] @enum_with_indirect_case_projectbox_copyvalue_deadend : $@convention(thin) (@guaranteed StructWithEnumWithIndirectCaseField) -> () {
2741
+ // CHECK-NOT: copy_value
2742
+ // CHECK: } // end sil function 'enum_with_indirect_case_projectbox_copyvalue_deadend'
2743
+ sil [ossa] @enum_with_indirect_case_projectbox_copyvalue_deadend : $@convention(thin) (@guaranteed StructWithEnumWithIndirectCaseField) -> () {
2744
+ bb0(%0 : @guaranteed $StructWithEnumWithIndirectCaseField):
2745
+ %1 = struct_extract %0 : $StructWithEnumWithIndirectCaseField, #StructWithEnumWithIndirectCaseField.field
2746
+ %1a = copy_value %1 : $EnumWithIndirectCase
2747
+ switch_enum %1a : $EnumWithIndirectCase, case #EnumWithIndirectCase.first!enumelt: bb1, case #EnumWithIndirectCase.second!enumelt: bb2
2748
+
2749
+ bb1:
2750
+ %9999 = tuple()
2751
+ return %9999 : $()
2752
+
2753
+ // NOTE: Eventually this will need to be changed when project_box has to be
2754
+ // guarded by begin_borrow.
2755
+ bb2(%2 : @owned ${ var Builtin.NativeObject }):
2756
+ %3 = project_box %2 : ${ var Builtin.NativeObject }, 0
2757
+ %4 = load [copy] %3 : $*Builtin.NativeObject
2758
+ %user = function_ref @guaranteed_user : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
2759
+ apply %user(%4) : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
2760
+ unreachable
2761
+ }
2762
+
2763
+ // CHECK-LABEL: sil [ossa] @enum_with_indirect_case_projectbox_loadcopy_to_loadborrow_deadend : $@convention(thin) (@in_guaranteed EnumWithIndirectCase) -> () {
2764
+ // CHECK: bb0
2765
+ // CHECK-NEXT: load_borrow
2766
+ // CHECK: } // end sil function 'enum_with_indirect_case_projectbox_loadcopy_to_loadborrow_deadend'
2767
+ sil [ossa] @enum_with_indirect_case_projectbox_loadcopy_to_loadborrow_deadend : $@convention(thin) (@in_guaranteed EnumWithIndirectCase) -> () {
2768
+ bb0(%0 : $*EnumWithIndirectCase):
2769
+ %1 = load [copy] %0 : $*EnumWithIndirectCase
2770
+ switch_enum %1 : $EnumWithIndirectCase, case #EnumWithIndirectCase.first!enumelt: bb1, case #EnumWithIndirectCase.second!enumelt: bb2
2771
+
2772
+ bb1:
2773
+ %9999 = tuple()
2774
+ return %9999 : $()
2775
+
2776
+ // NOTE: Eventually this will need to be changed when project_box has to be
2777
+ // guarded by begin_borrow.
2778
+ bb2(%2 : @owned ${ var Builtin.NativeObject }):
2779
+ %3 = project_box %2 : ${ var Builtin.NativeObject }, 0
2780
+ %4 = load [copy] %3 : $*Builtin.NativeObject
2781
+ %user = function_ref @guaranteed_user : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
2782
+ apply %user(%4) : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
2783
+ unreachable
2784
+ }
2785
+
2786
+ // CHECK-LABEL: sil [ossa] @enum_with_indirect_case_projectbox_loadcopy_to_loadborrow_deadend_2 : $@convention(thin) (@in_guaranteed EnumWithIndirectCase) -> () {
2787
+ // CHECK: bb0
2788
+ // CHECK-NEXT: load_borrow
2789
+ // CHECK: } // end sil function 'enum_with_indirect_case_projectbox_loadcopy_to_loadborrow_deadend_2'
2790
+ sil [ossa] @enum_with_indirect_case_projectbox_loadcopy_to_loadborrow_deadend_2 : $@convention(thin) (@in_guaranteed EnumWithIndirectCase) -> () {
2791
+ bb0(%0 : $*EnumWithIndirectCase):
2792
+ %1 = load [copy] %0 : $*EnumWithIndirectCase
2793
+ switch_enum %1 : $EnumWithIndirectCase, case #EnumWithIndirectCase.first!enumelt: bb1, case #EnumWithIndirectCase.second!enumelt: bb2
2794
+
2795
+ bb1:
2796
+ %9999 = tuple()
2797
+ return %9999 : $()
2798
+
2799
+ // NOTE: Eventually this will need to be changed when project_box has to be
2800
+ // guarded by begin_borrow.
2801
+ bb2(%2 : @owned ${ var Builtin.NativeObject }):
2802
+ %3 = project_box %2 : ${ var Builtin.NativeObject }, 0
2803
+ %4 = load [copy] %3 : $*Builtin.NativeObject
2804
+ %user = function_ref @guaranteed_user : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
2805
+ apply %user(%4) : $@convention(thin) (@guaranteed Builtin.NativeObject) -> ()
2806
+ destroy_value %2 : ${ var Builtin.NativeObject }
2807
+ unreachable
2808
+ }
0 commit comments