@@ -25,6 +25,13 @@ struct AggStruct {
25
25
var pair: KlassPair
26
26
}
27
27
28
+ @_moveOnly
29
+ struct SingleIntContainingStruct {
30
+ var value: Builtin.Int32
31
+ }
32
+
33
+ sil @misc_use : $@convention(thin) () -> ()
34
+
28
35
///////////
29
36
// Tests //
30
37
///////////
@@ -103,6 +110,33 @@ bb0(%0 : @owned $MoveOnlyKlass):
103
110
return %1 : $MoveOnlyKlass
104
111
}
105
112
113
+ // CHECK-LABEL: sil [ossa] @test_return_of_extracted_trivial_type : $@convention(thin) (@guaranteed SingleIntContainingStruct) -> Builtin.Int32 {
114
+ // CHECK: bb0([[ARG:%.*]] :
115
+ // CHECK: [[ARG_COPY:%.*]] = copy_value [[ARG]]
116
+ // CHECK: [[MARKED_ARG:%.*]] = mark_must_check [no_copy] [[ARG_COPY]]
117
+ // CHECK: [[MARKED_ARG_COPY:%.*]] = copy_value [[MARKED_ARG]]
118
+ // CHECK: [[MISC_USE:%.*]] = function_ref @misc_use : $@convention(thin) () -> ()
119
+ // CHECK: apply [[MISC_USE]]()
120
+ // CHECK: [[BORROW:%.*]] = begin_borrow [[MARKED_ARG_COPY]]
121
+ // CHECK: [[EXT:%.*]] = struct_extract [[BORROW]]
122
+ // CHECK: end_borrow [[BORROW]]
123
+ // CHECK: destroy_value [[MARKED_ARG_COPY]]
124
+ // CHECK: return [[EXT]]
125
+ // CHECK: } // end sil function 'test_return_of_extracted_trivial_type'
126
+ sil [ossa] @test_return_of_extracted_trivial_type : $@convention(thin) (@guaranteed SingleIntContainingStruct) -> Builtin.Int32 {
127
+ bb0(%0 : @guaranteed $SingleIntContainingStruct):
128
+ %1 = copy_value %0 : $SingleIntContainingStruct
129
+ %2 = mark_must_check [no_copy] %1 : $SingleIntContainingStruct
130
+ debug_value %2 : $SingleIntContainingStruct, let, name "x", argno 1
131
+ %4 = begin_borrow %2 : $SingleIntContainingStruct
132
+ %5 = struct_extract %4 : $SingleIntContainingStruct, #SingleIntContainingStruct.value
133
+ end_borrow %4 : $SingleIntContainingStruct
134
+ %f = function_ref @misc_use : $@convention(thin) () -> ()
135
+ apply %f() : $@convention(thin) () -> ()
136
+ destroy_value %2 : $SingleIntContainingStruct
137
+ return %5 : $Builtin.Int32
138
+ }
139
+
106
140
///////////////////////////////
107
141
// Single Field Struct Tests //
108
142
///////////////////////////////
0 commit comments