@@ -35,6 +35,16 @@ func testLocalWrapper() {
35
35
// CHECK: mark_function_escape [[P]] : $*Wrapper<Int>
36
36
// CHECK-LABEL: function_ref @$s22property_wrapper_local16testLocalWrapperyyF6$valueL_AA0F0VySiGvg : $@convention(thin) (@guaranteed { var Wrapper<Int> }) -> Wrapper<Int>
37
37
38
+ // Check that the wrapped value is materialized to a temporary when used as `inout`
39
+ value += 5
40
+ // CHECK: [[TMP:%.*]] = alloc_stack $Int
41
+ // CHECK: [[GET:%.*]] = function_ref @$s22property_wrapper_local16testLocalWrapperyyF5valueL_Sivg : $@convention(thin) (@guaranteed { var Wrapper<Int> }) -> Int
42
+ // CHECK: [[VAL:%.*]] = apply [[GET]]({{%.*}}) : $@convention(thin) (@guaranteed { var Wrapper<Int> }) -> Int
43
+ // CHECK: store [[VAL]] to [trivial] [[TMP]] : $*Int
44
+ // CHECK: [[OP:%.*]] = function_ref @$sSi2peoiyySiz_SitFZ : $@convention(method) (@inout Int, Int, @thin Int.Type) -> ()
45
+ // CHECK: apply [[OP]]({{%.*}}) : $@convention(method) (@inout Int, Int, @thin Int.Type) -> ()
46
+ // CHECK: [[RESULT:%.*]] = load [trivial] [[TMP]] : $*Int
47
+ // CHECK: assign_by_wrapper [[RESULT]] : $Int to [[P]]
38
48
39
49
// Check local property wrapper backing initializer and accessors
40
50
@@ -60,6 +70,12 @@ func testInitialValue() {
60
70
value = 15
61
71
// CHECK: function_ref @$s22property_wrapper_local16testInitialValueyyF5valueL_Sivs : $@convention(thin) (Int, @guaranteed { var Wrapper<Int> }) -> ()
62
72
// CHECK-NOT: assign_by_wrapper
73
+
74
+ value += 5
75
+ // CHECK: function_ref @$sSi2peoiyySiz_SitFZ : $@convention(method) (@inout Int, Int, @thin Int.Type) -> ()
76
+ // CHECK: function_ref @$s22property_wrapper_local16testInitialValueyyF5valueL_Sivs : $@convention(thin) (Int, @guaranteed { var Wrapper<Int> }) -> ()
77
+ // CHECK-NOT: assign_by_wrapper
78
+
63
79
// CHECK: return
64
80
65
81
// CHECK-LABEL: sil private [ossa] @$s22property_wrapper_local16testInitialValueyyF5valueL_SivpfP : $@convention(thin) (Int) -> Wrapper<Int> {
0 commit comments