@@ -235,36 +235,26 @@ internal class OtherClass {
235
235
}
236
236
237
237
// CHECK-LABEL: sil hidden [noinline] @$s25sil_combine_protocol_conf10OtherClassC12doWorkStructSiyF : $@convention(method) (@guaranteed OtherClass) -> Int {
238
- // CHECK: bb0
238
+ // CHECK: bb0([[ARG:%.*]] :
239
239
// CHECK: debug_value
240
- // CHECK: [[A1:%.*]] = alloc_stack $PropProtocol
241
- // CHECK: [[R1:%.*]] = ref_element_addr %0 : $OtherClass, #OtherClass.arg1
242
- // CHECK: copy_addr [[R1]] to [initialization] [[A1]] : $*PropProtocol
243
- // CHECK: [[O1:%.*]] = open_existential_addr immutable_access [[A1]] : $*PropProtocol to $*@opened("{{.*}}") PropProtocol
240
+ // CHECK: [[R1:%.*]] = ref_element_addr [[ARG]] : $OtherClass, #OtherClass.arg1
241
+ // CHECK: [[O1:%.*]] = open_existential_addr immutable_access [[R1]] : $*PropProtocol to $*@opened("{{.*}}") PropProtocol
244
242
// CHECK: [[U1:%.*]] = unchecked_addr_cast [[O1]] : $*@opened("{{.*}}") PropProtocol to $*PropClass
245
243
// CHECK: [[S1:%.*]] = struct_element_addr [[U1]] : $*PropClass, #PropClass.val
246
244
// CHECK: [[S11:%.*]] = struct_element_addr [[S1]] : $*Int, #Int._value
247
245
// CHECK: load [[S11]]
248
- // CHECK: destroy_addr [[A1]] : $*PropProtocol
249
- // CHECK: [[A2:%.*]] = alloc_stack $GenericPropProtocol
250
- // CHECK: [[R2:%.*]] = ref_element_addr %0 : $OtherClass, #OtherClass.arg2
251
- // CHECK: copy_addr [[R2]] to [initialization] [[A2]] : $*GenericPropProtocol
252
- // CHECK: [[O2:%.*]] = open_existential_addr immutable_access [[A2]] : $*GenericPropProtocol to $*@opened("{{.*}}") GenericPropProtocol
246
+ // CHECK: [[R2:%.*]] = ref_element_addr [[ARG]] : $OtherClass, #OtherClass.arg2
247
+ // CHECK: [[O2:%.*]] = open_existential_addr immutable_access [[R2]] : $*GenericPropProtocol to $*@opened("{{.*}}") GenericPropProtocol
253
248
// CHECK: [[W2:%.*]] = witness_method $@opened("{{.*}}") GenericPropProtocol, #GenericPropProtocol.val!getter.1 : <Self where Self : GenericPropProtocol> (Self) -> () -> Int, [[O2]] : $*@opened("{{.*}}") GenericPropProtocol : $@convention(witness_method: GenericPropProtocol) <τ_0_0 where τ_0_0 : GenericPropProtocol> (@in_guaranteed τ_0_0) -> Int
254
249
// CHECK: apply [[W2]]<@opened("{{.*}}") GenericPropProtocol>([[O2]]) : $@convention(witness_method: GenericPropProtocol) <τ_0_0 where τ_0_0 : GenericPropProtocol> (@in_guaranteed τ_0_0) -> Int
255
- // CHECK: destroy_addr [[A2]] : $*GenericPropProtocol
256
250
// CHECK: struct_extract
257
251
// CHECK: integer_literal
258
252
// CHECK: builtin
259
253
// CHECK: tuple_extract
260
254
// CHECK: tuple_extract
261
255
// CHECK: cond_fail
262
- // CHECK: dealloc_stack [[A2]] : $*GenericPropProtocol
263
- // CHECK: dealloc_stack [[A1]] : $*PropProtocol
264
- // CHECK: [[A4:%.*]] = alloc_stack $NestedPropProtocol
265
- // CHECK: [[R4:%.*]] = ref_element_addr %0 : $OtherClass, #OtherClass.arg3
266
- // CHECK: copy_addr [[R4]] to [initialization] [[A4]] : $*NestedPropProtocol
267
- // CHECK: [[O4:%.*]] = open_existential_addr immutable_access [[A4]] : $*NestedPropProtocol to $*@opened("{{.*}}") NestedPropProtocol
256
+ // CHECK: [[R4:%.*]] = ref_element_addr [[ARG]] : $OtherClass, #OtherClass.arg3
257
+ // CHECK: [[O4:%.*]] = open_existential_addr immutable_access [[R4]] : $*NestedPropProtocol to $*@opened("{{.*}}") NestedPropProtocol
268
258
// CHECK: [[U4:%.*]] = unchecked_addr_cast [[O4]] : $*@opened("{{.*}}") NestedPropProtocol to $*Outer.Inner
269
259
// CHECK: [[S4:%.*]] = struct_element_addr [[U4]] : $*Outer.Inner, #Outer.Inner.val
270
260
// CHECK: [[S41:%.*]] = struct_element_addr [[S4]] : $*Int, #Int._value
@@ -273,11 +263,8 @@ internal class OtherClass {
273
263
// CHECK: tuple_extract
274
264
// CHECK: tuple_extract
275
265
// CHECK: cond_fail
276
- // CHECK: dealloc_stack [[A4]] : $*NestedPropProtocol
277
- // CHECK: [[A5:%.*]] = alloc_stack $GenericNestedPropProtocol
278
- // CHECK: [[R5:%.*]] = ref_element_addr %0 : $OtherClass, #OtherClass.arg4
279
- // CHECK: copy_addr [[R5]] to [initialization] [[A5]] : $*GenericNestedPropProtocol
280
- // CHECK: [[O5:%.*]] = open_existential_addr immutable_access [[A5]] : $*GenericNestedPropProtocol to $*@opened("{{.*}}") GenericNestedPropProtocol
266
+ // CHECK: [[R5:%.*]] = ref_element_addr [[ARG]] : $OtherClass, #OtherClass.arg4
267
+ // CHECK: [[O5:%.*]] = open_existential_addr immutable_access [[R5]] : $*GenericNestedPropProtocol to $*@opened("{{.*}}") GenericNestedPropProtocol
281
268
// CHECK: [[W5:%.*]] = witness_method $@opened("{{.*}}") GenericNestedPropProtocol, #GenericNestedPropProtocol.val!getter.1 : <Self where Self : GenericNestedPropProtocol> (Self) -> () -> Int, [[O5:%.*]] : $*@opened("{{.*}}") GenericNestedPropProtocol : $@convention(witness_method: GenericNestedPropProtocol) <τ_0_0 where τ_0_0 : GenericNestedPropProtocol> (@in_guaranteed τ_0_0) -> Int
282
269
// CHECK: apply [[W5]]<@opened("{{.*}}") GenericNestedPropProtocol>([[O5]]) : $@convention(witness_method: GenericNestedPropProtocol) <τ_0_0 where τ_0_0 : GenericNestedPropProtocol> (@in_guaranteed τ_0_0) -> Int
283
270
// CHECK: struct_extract
@@ -286,8 +273,6 @@ internal class OtherClass {
286
273
// CHECK: tuple_extract
287
274
// CHECK: cond_fail
288
275
// CHECK: struct
289
- // CHECK: destroy_addr [[A5]] : $*GenericNestedPropProtocol
290
- // CHECK: dealloc_stack [[A5]] : $*GenericNestedPropProtocol
291
276
// CHECK: return
292
277
// CHECK: } // end sil function '$s25sil_combine_protocol_conf10OtherClassC12doWorkStructSiyF'
293
278
@inline ( never) func doWorkStruct ( ) -> Int {
@@ -301,6 +286,7 @@ internal class OtherClass {
301
286
// case 1: enum -- optimize
302
287
internal protocol AProtocol {
303
288
var val : Int { get }
289
+ mutating func getVal( ) -> Int
304
290
}
305
291
internal enum AnEnum : AProtocol {
306
292
case avalue
@@ -309,12 +295,14 @@ internal enum AnEnum : AProtocol {
309
295
case . avalue:
310
296
return 10
311
297
}
312
- }
298
+ }
299
+ mutating func getVal( ) -> Int { return self . val }
313
300
}
314
301
315
302
// case 2: generic enum -- do not optimize
316
303
internal protocol AGenericProtocol {
317
304
var val : Int { get }
305
+ mutating func getVal( ) -> Int
318
306
}
319
307
internal enum AGenericEnum < T> : AGenericProtocol {
320
308
case avalue
@@ -323,7 +311,11 @@ internal enum AGenericEnum<T> : AGenericProtocol {
323
311
case . avalue:
324
312
return 10
325
313
}
326
- }
314
+ }
315
+
316
+ mutating func getVal( ) -> Int {
317
+ return self . val
318
+ }
327
319
}
328
320
329
321
internal class OtherKlass {
@@ -336,13 +328,11 @@ internal class OtherKlass {
336
328
}
337
329
338
330
// CHECK-LABEL: sil hidden [noinline] @$s25sil_combine_protocol_conf10OtherKlassC10doWorkEnumSiyF : $@convention(method) (@guaranteed OtherKlass) -> Int {
339
- // CHECK: bb0
331
+ // CHECK: bb0([[ARG:%.*]] :
340
332
// CHECK: debug_value
341
333
// CHECK: integer_literal
342
- // CHECK: [[A1:%.*]] = alloc_stack $AGenericProtocol
343
- // CHECK: [[R1:%.*]] = ref_element_addr %0 : $OtherKlass, #OtherKlass.arg2
344
- // CHECK: copy_addr [[R1]] to [initialization] [[A1]] : $*AGenericProtocol
345
- // CHECK: [[O1:%.*]] = open_existential_addr immutable_access [[A1]] : $*AGenericProtocol to $*@opened("{{.*}}") AGenericProtocol
334
+ // CHECK: [[R1:%.*]] = ref_element_addr [[ARG]] : $OtherKlass, #OtherKlass.arg2
335
+ // CHECK: [[O1:%.*]] = open_existential_addr immutable_access [[R1]] : $*AGenericProtocol to $*@opened("{{.*}}") AGenericProtocol
346
336
// CHECK: [[W1:%.*]] = witness_method $@opened("{{.*}}") AGenericProtocol, #AGenericProtocol.val!getter.1 : <Self where Self : AGenericProtocol> (Self) -> () -> Int, [[O1]] : $*@opened("{{.*}}") AGenericProtocol : $@convention(witness_method: AGenericProtocol) <τ_0_0 where τ_0_0 : AGenericProtocol> (@in_guaranteed τ_0_0) -> Int
347
337
// CHECK: apply [[W1]]<@opened("{{.*}}") AGenericProtocol>([[O1]]) : $@convention(witness_method: AGenericProtocol) <τ_0_0 where τ_0_0 : AGenericProtocol> (@in_guaranteed τ_0_0) -> Int
348
338
// CHECK: struct_extract
@@ -352,8 +342,6 @@ internal class OtherKlass {
352
342
// CHECK: tuple_extract
353
343
// CHECK: cond_fail
354
344
// CHECK: struct
355
- // CHECK: destroy_addr [[A1]] : $*AGenericProtocol
356
- // CHECK: dealloc_stack [[A1]] : $*AGenericProtocol
357
345
// CHECK: return
358
346
// CHECK: } // end sil function '$s25sil_combine_protocol_conf10OtherKlassC10doWorkEnumSiyF'
359
347
@inline ( never) func doWorkEnum( ) -> Int {
0 commit comments