@@ -8,6 +8,16 @@ import Swift
8
8
public struct S {
9
9
var o: AnyObject
10
10
}
11
+
12
+ typealias Int1 = Builtin.Int1
13
+
14
+ class C {}
15
+
16
+ struct CAndBit {
17
+ var c: C
18
+ var bit: Int1
19
+ }
20
+
11
21
sil @dummy : $@convention(thin) () -> ()
12
22
13
23
// CHECK-LABEL: sil [ossa] @dead1 :
@@ -362,3 +372,38 @@ bb0(%0 : @guaranteed $S):
362
372
%8 = tuple ()
363
373
return %8 : $()
364
374
}
375
+
376
+ // CHECK-LABEL: sil [ossa] @dce_destroy_of_live_copy : {{.*}} {
377
+ // CHECK: [[COPY:%[^,]+]] = copy_value
378
+ // CHECK: cond_br {{%[^,]+}}, [[LEFT:bb[0-9]+]], [[RIGHT:bb[0-9]+]]
379
+ // CHECK: [[LEFT]]:
380
+ // CHECK: destroy_value [[COPY]]
381
+ // CHECK: br [[EXIT:bb[0-9]+]]
382
+ // CHECK: [[RIGHT]]:
383
+ // CHECK: destroy_value [[COPY]]
384
+ // CHECK: br [[EXIT]]
385
+ // CHECK: [[EXIT]]:
386
+ // CHECK-LABEL: } // end sil function 'dce_destroy_of_live_copy'
387
+ sil [ossa] @dce_destroy_of_live_copy : $@convention(thin) (Int1) -> () {
388
+ entry(%condition : $Int1):
389
+ %instance = apply undef() : $@convention(thin) () -> (@owned C)
390
+ %borrow = begin_borrow %instance : $C
391
+ %aggregate = struct $CAndBit(%borrow : $C, %condition : $Int1)
392
+ %copy = copy_value %aggregate : $CAndBit
393
+ end_borrow %borrow : $C
394
+ %borrow2 = begin_borrow %copy : $CAndBit
395
+ %bit = struct_extract %borrow2 : $CAndBit, #CAndBit.bit
396
+ end_borrow %borrow2 : $CAndBit
397
+ apply undef(%bit) : $@convention(thin) (Int1) -> ()
398
+ cond_br %condition, left, right
399
+ left:
400
+ destroy_value %copy : $CAndBit
401
+ br exit
402
+ right:
403
+ destroy_value %copy : $CAndBit
404
+ br exit
405
+ exit:
406
+ destroy_value %instance : $C
407
+ %retval = tuple ()
408
+ return %retval : $()
409
+ }
0 commit comments