@@ -15,6 +15,8 @@ enum Optional<T> {
15
15
case some(T)
16
16
}
17
17
18
+ struct S {}
19
+
18
20
struct SRef<T> {
19
21
@_hasStorage var object: AnyObject { get set }
20
22
@_hasStorage var element: T { get set }
@@ -470,3 +472,67 @@ bb2:
470
472
bb3(%phi : @owned $T):
471
473
return %phi : $T
472
474
}
475
+
476
+ // Check that the debug_value instruction that is created when deleting a load
477
+ // gets rewritten and doesn't obstruct the deletion of the phi.
478
+ // CHECK-LABEL: sil [ossa] @f100_store_phi : {{.*}} {
479
+ // CHECK: {{bb[0-9]+}}({{%[^,]+}} : $*Value):
480
+ // CHECK: [[TEMP:%[^,]+]] = alloc_stack $Value
481
+ // CHECK: [[VAR:%[^,]+]] = alloc_stack [lexical] $Value, var, name "value"
482
+ // CHECK: cond_br undef, bb2, bb1
483
+ // CHECK: bb3:
484
+ // CHECK: copy_addr [take] [[TEMP]] to [init] [[VAR]]
485
+ // CHECK: debug_value [[TEMP]] : $*Value, var, name "value"
486
+ // CHECK-LABEL: } // end sil function 'f100_store_phi'
487
+ sil [ossa] @f100_store_phi : $@convention(thin) <Value> (@in Value) -> () {
488
+ entry(%instance : @owned $Value):
489
+ %14 = alloc_stack [lexical] $Value, var, name "value"
490
+ cond_br undef, left, right
491
+
492
+ left:
493
+ br merge(%instance : $Value)
494
+
495
+ right:
496
+ br merge(%instance : $Value)
497
+
498
+ merge(%34 : @owned $Value):
499
+ store %34 to [init] %14 : $*Value
500
+ destroy_addr %14 : $*Value
501
+ dealloc_stack %14 : $*Value
502
+ %43 = tuple ()
503
+ return %43 : $()
504
+ }
505
+
506
+ // CHECK-LABEL: sil [ossa] @f105_phi_into_tuple : {{.*}} {
507
+ // CHECK: [[STORAGE:%[^,]+]] = alloc_stack $(Self, Builtin.Int1)
508
+ // CHECK: [[SELF_ADDR:%[^,]+]] = tuple_element_addr [[STORAGE]]
509
+ // CHECK: apply {{%[^,]+}}<Self>([[SELF_ADDR]])
510
+ // CHECK-LABEL: } // end sil function 'f105_phi_into_tuple'
511
+ sil [ossa] @f105_phi_into_tuple : $@convention(thin) <Self> () -> () {
512
+ %getOut = function_ref @getOut : $@convention(thin) <T> () -> @out T
513
+ %self = apply %getOut<Self>() : $@convention(thin) <τ_0_0> () -> @out τ_0_0
514
+ br exit(%self : $Self)
515
+
516
+ exit(%self_2 : @owned $Self):
517
+ %tuple = tuple (%self_2 : $Self, undef : $Bool)
518
+ destroy_value %tuple : $(Self, Bool)
519
+ %retval = tuple ()
520
+ return %retval : $()
521
+ }
522
+
523
+ // Check deleting the first of multiple block arguments.
524
+ // CHECK-LABEL: sil [ossa] @f110_nonfinal_argument : {{.*}} {
525
+ // CHECK: bb3({{%[^,]+}} : $S):
526
+ // CHECK-LABEL: } // end sil function 'f110_nonfinal_argument'
527
+ sil [ossa] @f110_nonfinal_argument : $@convention(thin) <T> (@in T, S) -> () {
528
+ entry(%instance : @owned $T, %s : $S):
529
+ cond_br undef, left, right
530
+ left:
531
+ br exit(%instance : $T, %s : $S)
532
+ right:
533
+ br exit(%instance : $T, %s : $S)
534
+ exit(%instance_2 : @owned $T, %s_2 : $S):
535
+ destroy_value %instance_2 : $T
536
+ %retval = tuple ()
537
+ return %retval : $()
538
+ }
0 commit comments