@@ -16,6 +16,7 @@ import Foundation
16
16
17
17
struct DataWrapper {
18
18
let data: Data
19
+ let otherData: Data
19
20
}
20
21
21
22
sil @getData : $@convention(thin) () -> @owned Data
@@ -200,6 +201,30 @@ bb0(%0: @owned $MyObject):
200
201
return %51 : $Optional<NSData>
201
202
}
202
203
204
+ // Not optimized
205
+ // CHECK-LABEL: sil [Osize] [ossa] @test_struct_guaranteed :
206
+ // CHECK: objc_method
207
+ // CHECK-LABEL: } // end sil function 'test_struct_guaranteed'
208
+ sil [Osize] [ossa] @test_struct_guaranteed : $@convention(thin) (@owned MyObject) -> @owned Optional<NSData> {
209
+ bb0(%0 : @owned $MyObject):
210
+ %1 = metatype $@objc_metatype MyObject.Type
211
+ %2 = function_ref @getData : $@convention(thin) () -> @owned Data
212
+ %3 = apply %2() : $@convention(thin) () -> @owned Data
213
+ %4 = begin_borrow %3
214
+ %5 = struct $DataWrapper (%4, %4)
215
+ %6 = struct_extract %5, #DataWrapper.data
216
+ %7 = function_ref @$s10Foundation4DataV19_bridgeToObjectiveCSo6NSDataCyF : $@convention(method) (@guaranteed Data) -> @owned NSData
217
+ %8 = apply %7(%6) : $@convention(method) (@guaranteed Data) -> @owned NSData
218
+ %9 = enum $Optional<NSData>, #Optional.some!enumelt, %8
219
+ end_borrow %4
220
+ %13 = objc_method %1, #MyObject.take!foreign : (MyObject.Type) -> (Data?) -> Data?, $@convention(objc_method) (Optional<NSData>, @objc_metatype MyObject.Type) -> @autoreleased Optional<NSData>
221
+ %14 = apply %13(%9, %1) : $@convention(objc_method) (Optional<NSData>, @objc_metatype MyObject.Type) -> @autoreleased Optional<NSData>
222
+ destroy_value %0
223
+ destroy_value %3
224
+ destroy_value %9
225
+ return %14
226
+ }
227
+
203
228
sil [Osize] [ossa] @test_dont_crash : $@convention(thin) (@owned MyObject) -> () {
204
229
bb0(%0: @owned $MyObject):
205
230
%35 = metatype $@objc_metatype MyObject.Type
0 commit comments