@@ -496,3 +496,33 @@ bb0(%0 : @owned $NotTrivial):
496
496
%6 = tuple ()
497
497
return %6 : $()
498
498
}
499
+
500
+ // CHECK-LABEL: sil [ossa] @struct_with_obj_fields_multiple_stores :
501
+ // CHECK: bb0([[ARG_0:%[0-9]+]] : @owned $NotTrivial, [[ARG_1:%[0-9]+]] : @owned $NotTrivial):
502
+ // CHECK: [[VAR_1:%[0-9]+]] = alloc_stack $Obj
503
+ // CHECK: [[VAR_2:%[0-9]+]] = alloc_stack $Obj
504
+ // CHECK: ([[VAR_4:%[0-9]+]], [[VAR_6:%[0-9]+]]) = destructure_struct [[ARG_0]]
505
+ // CHECK: store [[VAR_4]] to [init] [[VAR_1]] : $*Obj
506
+ // CHECK: store [[VAR_6]] to [init] [[VAR_2]] : $*Obj
507
+ // CHECK: ([[VAR_4a:%[0-9]+]], [[VAR_6a:%[0-9]+]]) = destructure_struct [[ARG_1]]
508
+ // Make sure we use [assign] here
509
+ // CHECK: store [[VAR_4a]] to [assign] [[VAR_1]] : $*Obj
510
+ // CHECK: store [[VAR_6a]] to [assign] [[VAR_2]] : $*Obj
511
+ // CHECK-LABEL: } // end sil function 'struct_with_obj_fields_multiple_stores'
512
+ sil [ossa] @struct_with_obj_fields_multiple_stores : $@convention(thin) (@owned NotTrivial, @owned NotTrivial) -> () {
513
+ bb0(%0 : @owned $NotTrivial, %1 : @owned $NotTrivial):
514
+ %stk = alloc_stack $NotTrivial
515
+ store %0 to [init] %stk : $*NotTrivial
516
+ %3 = struct_element_addr %stk : $*NotTrivial, #NotTrivial.y
517
+ %4 = load [copy] %3 : $*Obj
518
+ %2 = function_ref @use_obj : $@convention(thin) (@owned Obj) -> ()
519
+ apply %2(%4) : $@convention(thin) (@owned Obj) -> ()
520
+ store %1 to [assign] %stk : $*NotTrivial
521
+ %4a = load [copy] %3 : $*Obj
522
+ apply %2(%4a) : $@convention(thin) (@owned Obj) -> ()
523
+ %5 = load [take] %stk : $*NotTrivial
524
+ destroy_value %5 : $NotTrivial
525
+ dealloc_stack %stk : $*NotTrivial
526
+ %6 = tuple ()
527
+ return %6 : $()
528
+ }
0 commit comments