Skip to content

Commit c3c61b4

Browse files
committed
Additional test
1 parent 6f940b4 commit c3c61b4

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

test/SILOptimizer/moveonly_borrow_to_destructure_transform.sil

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ struct AggStruct {
2525
var pair: KlassPair
2626
}
2727

28+
@_moveOnly
29+
struct SingleIntContainingStruct {
30+
var value: Builtin.Int32
31+
}
32+
33+
sil @misc_use : $@convention(thin) () -> ()
34+
2835
///////////
2936
// Tests //
3037
///////////
@@ -103,6 +110,33 @@ bb0(%0 : @owned $MoveOnlyKlass):
103110
return %1 : $MoveOnlyKlass
104111
}
105112

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+
106140
///////////////////////////////
107141
// Single Field Struct Tests //
108142
///////////////////////////////

0 commit comments

Comments
 (0)