@@ -375,6 +375,91 @@ bb1(%copy2 : @owned $NonTrivialStruct, %borrow2 : @guaranteed $NonTrivialStruct)
375
375
return %newcopy : $NonTrivialStruct
376
376
}
377
377
378
+ // CHECK-LABEL: sil [ossa] @dce_borrowlifetime2 :
379
+ // CHECK: bb1:
380
+ // CHECK-LABEL: } // end sil function 'dce_borrowlifetime2'
381
+ sil [ossa] @dce_borrowlifetime2 : $@convention(thin) (@guaranteed Klass) -> () {
382
+ bb0(%0 : @guaranteed $Klass):
383
+ %copy = copy_value %0 : $Klass
384
+ %borrow = begin_borrow %copy : $Klass
385
+ %2 = function_ref @$use_klass2 : $@convention(thin) (@guaranteed Klass) -> ()
386
+ %3 = apply %2(%borrow) : $@convention(thin) (@guaranteed Klass) -> ()
387
+ %5 = apply %2(%copy) : $@convention(thin) (@guaranteed Klass) -> ()
388
+ br bb1(%copy : $Klass, %borrow : $Klass)
389
+
390
+ bb1(%copy2 : @owned $Klass, %borrow2 : @guaranteed $Klass):
391
+ end_borrow %borrow2 : $Klass
392
+ destroy_value %copy2 : $Klass
393
+ %res = tuple ()
394
+ return %res : $()
395
+ }
396
+
397
+ // CHECK-LABEL: sil [ossa] @dce_borrowlifetime3 :
398
+ // CHECK: bb1:
399
+ // CHECK-LABEL: } // end sil function 'dce_borrowlifetime3'
400
+ sil [ossa] @dce_borrowlifetime3 : $@convention(thin) (@guaranteed Klass) -> () {
401
+ bb0(%0 : @guaranteed $Klass):
402
+ %copy = copy_value %0 : $Klass
403
+ %borrow = begin_borrow %copy : $Klass
404
+ %2 = function_ref @$use_klass2 : $@convention(thin) (@guaranteed Klass) -> ()
405
+ %3 = apply %2(%borrow) : $@convention(thin) (@guaranteed Klass) -> ()
406
+ %5 = apply %2(%copy) : $@convention(thin) (@guaranteed Klass) -> ()
407
+ br bb1(%borrow : $Klass, %copy : $Klass)
408
+
409
+ bb1(%borrow2 : @guaranteed $Klass, %copy2 : @owned $Klass):
410
+ end_borrow %borrow2 : $Klass
411
+ destroy_value %copy2 : $Klass
412
+ %res = tuple ()
413
+ return %res : $()
414
+ }
415
+
416
+ // CHECK-LABEL: sil [ossa] @dce_borrowlifetime4 :
417
+ // CHECK: bb1:
418
+ // CHECK-LABEL: } // end sil function 'dce_borrowlifetime4'
419
+ sil [ossa] @dce_borrowlifetime4 : $@convention(thin) (@guaranteed Klass) -> () {
420
+ bb0(%0 : @guaranteed $Klass):
421
+ %copy = copy_value %0 : $Klass
422
+ %borrow = begin_borrow %copy : $Klass
423
+ %2 = function_ref @$use_klass2 : $@convention(thin) (@guaranteed Klass) -> ()
424
+ %3 = apply %2(%borrow) : $@convention(thin) (@guaranteed Klass) -> ()
425
+ %5 = apply %2(%copy) : $@convention(thin) (@guaranteed Klass) -> ()
426
+ br bb1(%borrow : $Klass)
427
+
428
+ bb1(%borrow2 : @guaranteed $Klass):
429
+ end_borrow %borrow2 : $Klass
430
+ br bb2(%copy : $Klass)
431
+
432
+ bb2(%copy2 : @owned $Klass):
433
+ destroy_value %copy2 : $Klass
434
+ %res = tuple ()
435
+ return %res : $()
436
+ }
437
+
438
+ // CHECK-LABEL: sil [ossa] @dce_borrowlifetime5 :
439
+ // CHECK: bb1:
440
+ // CHECK-LABEL: } // end sil function 'dce_borrowlifetime5'
441
+ sil [ossa] @dce_borrowlifetime5 : $@convention(thin) (@guaranteed Klass) -> () {
442
+ bb0(%0 : @guaranteed $Klass):
443
+ %copy1 = copy_value %0 : $Klass
444
+ %copy2 = copy_value %0 : $Klass
445
+ %borrow1 = begin_borrow %copy1 : $Klass
446
+ %borrow2 = begin_borrow %copy2 : $Klass
447
+ %2 = function_ref @$use_klass2 : $@convention(thin) (@guaranteed Klass) -> ()
448
+ %3 = apply %2(%borrow1) : $@convention(thin) (@guaranteed Klass) -> ()
449
+ %4 = apply %2(%borrow2) : $@convention(thin) (@guaranteed Klass) -> ()
450
+ %5 = apply %2(%copy1) : $@convention(thin) (@guaranteed Klass) -> ()
451
+ %6 = apply %2(%copy2) : $@convention(thin) (@guaranteed Klass) -> ()
452
+ br bb1(%copy1 : $Klass, %borrow1 : $Klass, %borrow2 : $Klass)
453
+
454
+ bb1(%newcopy : @owned $Klass, %newborrow1 : @guaranteed $Klass, %newborrow2 : @guaranteed $Klass):
455
+ end_borrow %newborrow1 : $Klass
456
+ end_borrow %newborrow2 : $Klass
457
+ destroy_value %newcopy : $Klass
458
+ destroy_value %copy2 : $Klass
459
+ %res = tuple ()
460
+ return %res : $()
461
+ }
462
+
378
463
// CHECK-LABEL: sil [ossa] @infinite_loop :
379
464
// CHECK-NOT: copy_value
380
465
// CHECK-LABEL: } // end sil function 'infinite_loop'
0 commit comments