@@ -35,6 +35,16 @@ func testLocalWrapper() {
3535 // CHECK: mark_function_escape [[P]] : $*Wrapper<Int>
3636 // CHECK-LABEL: function_ref @$s22property_wrapper_local16testLocalWrapperyyF6$valueL_AA0F0VySiGvg : $@convention(thin) (@guaranteed { var Wrapper<Int> }) -> Wrapper<Int>
3737
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]]
3848
3949 // Check local property wrapper backing initializer and accessors
4050
@@ -60,6 +70,12 @@ func testInitialValue() {
6070 value = 15
6171 // CHECK: function_ref @$s22property_wrapper_local16testInitialValueyyF5valueL_Sivs : $@convention(thin) (Int, @guaranteed { var Wrapper<Int> }) -> ()
6272 // 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+
6379 // CHECK: return
6480
6581 // CHECK-LABEL: sil private [ossa] @$s22property_wrapper_local16testInitialValueyyF5valueL_SivpfP : $@convention(thin) (Int) -> Wrapper<Int> {
0 commit comments