Skip to content

Commit 588b578

Browse files
committed
[Exclusivity] Update SILGen tests for static access markers.
1 parent 48ecd6d commit 588b578

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+558
-288
lines changed

test/SILGen/address_only_types.swift

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,8 @@ func address_only_assignment_from_temp(_ dest: inout Unloadable) {
161161
// CHECK: bb0([[DEST:%[0-9]+]] : $*Unloadable):
162162
dest = some_address_only_function_1()
163163
// CHECK: [[TEMP:%[0-9]+]] = alloc_stack $Unloadable
164-
// CHECK: copy_addr [take] [[TEMP]] to %0 :
164+
// CHECK: %[[ACCESS:.*]] = begin_access [modify] [unknown] %0 :
165+
// CHECK: copy_addr [take] [[TEMP]] to %[[ACCESS]] :
165166
// CHECK-NOT: destroy_addr [[TEMP]]
166167
// CHECK: dealloc_stack [[TEMP]]
167168
}
@@ -174,8 +175,11 @@ func address_only_assignment_from_lv(_ dest: inout Unloadable, v: Unloadable) {
174175
// CHECK: [[PBOX:%[0-9]+]] = project_box [[VBOX]]
175176
// CHECK: copy_addr [[VARG]] to [initialization] [[PBOX]] : $*Unloadable
176177
dest = v
177-
// FIXME: emit into?
178-
// CHECK: copy_addr [[PBOX]] to %0 :
178+
// CHECK: [[READBOX:%.*]] = begin_access [read] [unknown] [[PBOX]] :
179+
// CHECK: [[TEMP:%[0-9]+]] = alloc_stack $Unloadable
180+
// CHECK: copy_addr [[READBOX]] to [initialization] [[TEMP]] :
181+
// CHECK: [[RET:%.*]] = begin_access [modify] [unknown] %0 :
182+
// CHECK: copy_addr [take] [[TEMP]] to [[RET]] :
179183
// CHECK: destroy_value [[VBOX]]
180184
}
181185

@@ -216,7 +220,8 @@ func address_only_var() -> Unloadable {
216220
// CHECK: [[XPB:%.*]] = project_box [[XBOX]]
217221
// CHECK: apply {{%.*}}([[XPB]])
218222
return x
219-
// CHECK: copy_addr [[XPB]] to [initialization] [[RET]]
223+
// CHECK: [[ACCESS:%.*]] = begin_access [read] [unknown] [[XPB]] :
224+
// CHECK: copy_addr [[ACCESS]] to [initialization] %0
220225
// CHECK: destroy_value [[XBOX]]
221226
// CHECK: return
222227
}

test/SILGen/addressors.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,9 @@ struct D : Subscriptable {
178178
// SILGEN: debug_value [[VALUE]] : $Int32
179179
// SILGEN: debug_value [[I]] : $Int32
180180
// SILGEN: debug_value_addr [[SELF]]
181+
// SILGEN: [[ACCESS:%.*]] = begin_access [modify] [unknown] [[SELF]] : $*D // users: %12, %8
181182
// SILGEN: [[T0:%.*]] = function_ref @_T010addressors1DV9subscripts5Int32VAFcfau{{.*}}
182-
// SILGEN: [[PTR:%.*]] = apply [[T0]]([[I]], [[SELF]])
183+
// SILGEN: [[PTR:%.*]] = apply [[T0]]([[I]], [[ACCESS]])
183184
// SILGEN: [[T0:%.*]] = struct_extract [[PTR]] : $UnsafeMutablePointer<Int32>,
184185
// SILGEN: [[ADDR:%.*]] = pointer_to_address [[T0]] : $Builtin.RawPointer to [strict] $*Int32
185186
// SILGEN: assign [[VALUE]] to [[ADDR]] : $*Int32

test/SILGen/borrow.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ func useD(_ d: D) {}
1717
// CHECK: [[BOX:%.*]] = alloc_box ${ var C }, var, name "c"
1818
// CHECK: [[PB_BOX:%.*]] = project_box [[BOX]]
1919
// CHECK: [[FUNC:%.*]] = function_ref @_T06borrow4useD{{.*}} : $@convention(thin) (@owned D) -> ()
20-
// CHECK: [[CLASS:%.*]] = load [copy] [[PB_BOX]]
20+
// CHECK: [[ACCESS:%.*]] = begin_access [read] [unknown] [[PB_BOX]] : $*C
21+
// CHECK: [[CLASS:%.*]] = load [copy] [[ACCESS]]
2122
// CHECK: [[BORROWED_CLASS:%.*]] = begin_borrow [[CLASS]]
2223
// CHECK: [[OFFSET:%.*]] = ref_element_addr [[BORROWED_CLASS]]
2324
// CHECK: [[LOADED_VALUE:%.*]] = load [copy] [[OFFSET]]

test/SILGen/boxed_existentials.swift

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ func test_property_of_lvalue(_ x: Error) -> String {
8484
// CHECK: [[BORROWED_ARG:%.*]] = begin_borrow [[ARG]]
8585
// CHECK: [[ARG_COPY:%.*]] = copy_value [[BORROWED_ARG]] : $Error
8686
// CHECK: store [[ARG_COPY]] to [init] [[PVAR]]
87-
// CHECK: [[VALUE_BOX:%.*]] = load [copy] [[PVAR]]
87+
// CHECK: [[ACCESS:%.*]] = begin_access [read] [unknown] [[PVAR]] : $*Error
88+
// CHECK: [[VALUE_BOX:%.*]] = load [copy] [[ACCESS]]
8889
// CHECK: [[VALUE:%.*]] = open_existential_box [[VALUE_BOX]] : $Error to $*[[VALUE_TYPE:@opened\(.*\) Error]]
8990
// CHECK: [[COPY:%.*]] = alloc_stack $[[VALUE_TYPE]]
9091
// CHECK: copy_addr [[VALUE]] to [initialization] [[COPY]]
@@ -150,7 +151,8 @@ func test_open_existential_semantics(_ guaranteed: Error,
150151
// GUARANTEED-NOT: destroy_value [[ARG0]]
151152
guaranteed.extensionMethod()
152153

153-
// CHECK: [[IMMEDIATE:%.*]] = load [copy] [[PB]]
154+
// CHECK: [[ACCESS:%.*]] = begin_access [read] [unknown] [[PB]] : $*Error
155+
// CHECK: [[IMMEDIATE:%.*]] = load [copy] [[ACCESS]]
154156
// -- need a copy_value to guarantee
155157
// CHECK: [[VALUE:%.*]] = open_existential_box [[IMMEDIATE]]
156158
// CHECK: [[METHOD:%.*]] = function_ref
@@ -161,7 +163,8 @@ func test_open_existential_semantics(_ guaranteed: Error,
161163
// out.
162164
// CHECK: destroy_value [[IMMEDIATE]]
163165

164-
// GUARANTEED: [[IMMEDIATE:%.*]] = load [copy] [[PB]]
166+
// GUARANTEED: [[ACCESS:%.*]] = begin_access [read] [unknown] [[PB]] : $*Error
167+
// GUARANTEED: [[IMMEDIATE:%.*]] = load [copy] [[ACCESS]]
165168
// -- need a copy_value to guarantee
166169
// GUARANTEED: [[VALUE:%.*]] = open_existential_box [[IMMEDIATE]]
167170
// GUARANTEED: [[METHOD:%.*]] = function_ref
@@ -203,7 +206,8 @@ func erasure_to_any(_ guaranteed: Error, _ immediate: Error) -> Any {
203206
// CHECK-NOT: destroy_value [[GUAR]]
204207
return guaranteed
205208
} else if true {
206-
// CHECK: [[IMMEDIATE:%.*]] = load [copy] [[PB]]
209+
// CHECK: [[ACCESS:%.*]] = begin_access [read] [unknown] [[PB]]
210+
// CHECK: [[IMMEDIATE:%.*]] = load [copy] [[ACCESS]]
207211
// CHECK: [[FROM_VALUE:%.*]] = open_existential_box [[IMMEDIATE]]
208212
// CHECK: [[TO_VALUE:%.*]] = init_existential_addr [[OUT]]
209213
// CHECK: copy_addr [[FROM_VALUE]] to [initialization] [[TO_VALUE]]

test/SILGen/builtins.swift

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -670,7 +670,8 @@ func pinUnpin(_ object : Builtin.NativeObject) {
670670
// NativeObject
671671
// CHECK-LABEL: sil hidden @_T08builtins8isUnique{{[_0-9a-zA-Z]*}}F
672672
// CHECK: bb0(%0 : $*Optional<Builtin.NativeObject>):
673-
// CHECK: [[BUILTIN:%.*]] = is_unique %0 : $*Optional<Builtin.NativeObject>
673+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0 : $*Optional<Builtin.NativeObject>
674+
// CHECK: [[BUILTIN:%.*]] = is_unique [[WRITE]] : $*Optional<Builtin.NativeObject>
674675
// CHECK: return
675676
func isUnique(_ ref: inout Builtin.NativeObject?) -> Bool {
676677
return _getBool(Builtin.isUnique(&ref))
@@ -679,7 +680,8 @@ func isUnique(_ ref: inout Builtin.NativeObject?) -> Bool {
679680
// NativeObject nonNull
680681
// CHECK-LABEL: sil hidden @_T08builtins8isUnique{{[_0-9a-zA-Z]*}}F
681682
// CHECK: bb0(%0 : $*Builtin.NativeObject):
682-
// CHECK: [[BUILTIN:%.*]] = is_unique %0 : $*Builtin.NativeObject
683+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0
684+
// CHECK: [[BUILTIN:%.*]] = is_unique [[WRITE]] : $*Builtin.NativeObject
683685
// CHECK: return
684686
func isUnique(_ ref: inout Builtin.NativeObject) -> Bool {
685687
return _getBool(Builtin.isUnique(&ref))
@@ -688,7 +690,8 @@ func isUnique(_ ref: inout Builtin.NativeObject) -> Bool {
688690
// NativeObject pinned
689691
// CHECK-LABEL: sil hidden @_T08builtins16isUniqueOrPinned{{[_0-9a-zA-Z]*}}F
690692
// CHECK: bb0(%0 : $*Optional<Builtin.NativeObject>):
691-
// CHECK: [[BUILTIN:%.*]] = is_unique_or_pinned %0 : $*Optional<Builtin.NativeObject>
693+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0
694+
// CHECK: [[BUILTIN:%.*]] = is_unique_or_pinned [[WRITE]] : $*Optional<Builtin.NativeObject>
692695
// CHECK: return
693696
func isUniqueOrPinned(_ ref: inout Builtin.NativeObject?) -> Bool {
694697
return _getBool(Builtin.isUniqueOrPinned(&ref))
@@ -697,7 +700,8 @@ func isUniqueOrPinned(_ ref: inout Builtin.NativeObject?) -> Bool {
697700
// NativeObject pinned nonNull
698701
// CHECK-LABEL: sil hidden @_T08builtins16isUniqueOrPinned{{[_0-9a-zA-Z]*}}F
699702
// CHECK: bb0(%0 : $*Builtin.NativeObject):
700-
// CHECK: [[BUILTIN:%.*]] = is_unique_or_pinned %0 : $*Builtin.NativeObject
703+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0
704+
// CHECK: [[BUILTIN:%.*]] = is_unique_or_pinned [[WRITE]] : $*Builtin.NativeObject
701705
// CHECK: return
702706
func isUniqueOrPinned(_ ref: inout Builtin.NativeObject) -> Bool {
703707
return _getBool(Builtin.isUniqueOrPinned(&ref))
@@ -706,7 +710,8 @@ func isUniqueOrPinned(_ ref: inout Builtin.NativeObject) -> Bool {
706710
// UnknownObject (ObjC)
707711
// CHECK-LABEL: sil hidden @_T08builtins8isUnique{{[_0-9a-zA-Z]*}}F
708712
// CHECK: bb0(%0 : $*Optional<Builtin.UnknownObject>):
709-
// CHECK: [[BUILTIN:%.*]] = is_unique %0 : $*Optional<Builtin.UnknownObject>
713+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0
714+
// CHECK: [[BUILTIN:%.*]] = is_unique [[WRITE]] : $*Optional<Builtin.UnknownObject>
710715
// CHECK: return
711716
func isUnique(_ ref: inout Builtin.UnknownObject?) -> Bool {
712717
return _getBool(Builtin.isUnique(&ref))
@@ -715,7 +720,8 @@ func isUnique(_ ref: inout Builtin.UnknownObject?) -> Bool {
715720
// UnknownObject (ObjC) nonNull
716721
// CHECK-LABEL: sil hidden @_T08builtins8isUnique{{[_0-9a-zA-Z]*}}F
717722
// CHECK: bb0(%0 : $*Builtin.UnknownObject):
718-
// CHECK: [[BUILTIN:%.*]] = is_unique %0 : $*Builtin.UnknownObject
723+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0
724+
// CHECK: [[BUILTIN:%.*]] = is_unique [[WRITE]] : $*Builtin.UnknownObject
719725
// CHECK: return
720726
func isUnique(_ ref: inout Builtin.UnknownObject) -> Bool {
721727
return _getBool(Builtin.isUnique(&ref))
@@ -724,7 +730,8 @@ func isUnique(_ ref: inout Builtin.UnknownObject) -> Bool {
724730
// UnknownObject (ObjC) pinned nonNull
725731
// CHECK-LABEL: sil hidden @_T08builtins16isUniqueOrPinned{{[_0-9a-zA-Z]*}}F
726732
// CHECK: bb0(%0 : $*Builtin.UnknownObject):
727-
// CHECK: [[BUILTIN:%.*]] = is_unique_or_pinned %0 : $*Builtin.UnknownObject
733+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0
734+
// CHECK: [[BUILTIN:%.*]] = is_unique_or_pinned [[WRITE]] : $*Builtin.UnknownObject
728735
// CHECK: return
729736
func isUniqueOrPinned(_ ref: inout Builtin.UnknownObject) -> Bool {
730737
return _getBool(Builtin.isUniqueOrPinned(&ref))
@@ -733,7 +740,8 @@ func isUniqueOrPinned(_ ref: inout Builtin.UnknownObject) -> Bool {
733740
// BridgeObject nonNull
734741
// CHECK-LABEL: sil hidden @_T08builtins8isUnique{{[_0-9a-zA-Z]*}}F
735742
// CHECK: bb0(%0 : $*Builtin.BridgeObject):
736-
// CHECK: [[BUILTIN:%.*]] = is_unique %0 : $*Builtin.BridgeObject
743+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0
744+
// CHECK: [[BUILTIN:%.*]] = is_unique [[WRITE]] : $*Builtin.BridgeObject
737745
// CHECK: return
738746
func isUnique(_ ref: inout Builtin.BridgeObject) -> Bool {
739747
return _getBool(Builtin.isUnique(&ref))
@@ -742,7 +750,8 @@ func isUnique(_ ref: inout Builtin.BridgeObject) -> Bool {
742750
// BridgeObject pinned nonNull
743751
// CHECK-LABEL: sil hidden @_T08builtins16isUniqueOrPinned{{[_0-9a-zA-Z]*}}F
744752
// CHECK: bb0(%0 : $*Builtin.BridgeObject):
745-
// CHECK: [[BUILTIN:%.*]] = is_unique_or_pinned %0 : $*Builtin.BridgeObject
753+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0
754+
// CHECK: [[BUILTIN:%.*]] = is_unique_or_pinned [[WRITE]] : $*Builtin.BridgeObject
746755
// CHECK: return
747756
func isUniqueOrPinned(_ ref: inout Builtin.BridgeObject) -> Bool {
748757
return _getBool(Builtin.isUniqueOrPinned(&ref))
@@ -751,7 +760,8 @@ func isUniqueOrPinned(_ ref: inout Builtin.BridgeObject) -> Bool {
751760
// BridgeObject nonNull native
752761
// CHECK-LABEL: sil hidden @_T08builtins15isUnique_native{{[_0-9a-zA-Z]*}}F
753762
// CHECK: bb0(%0 : $*Builtin.BridgeObject):
754-
// CHECK: [[CAST:%.*]] = unchecked_addr_cast %0 : $*Builtin.BridgeObject to $*Builtin.NativeObject
763+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0
764+
// CHECK: [[CAST:%.*]] = unchecked_addr_cast [[WRITE]] : $*Builtin.BridgeObject to $*Builtin.NativeObject
755765
// CHECK: return
756766
func isUnique_native(_ ref: inout Builtin.BridgeObject) -> Bool {
757767
return _getBool(Builtin.isUnique_native(&ref))
@@ -760,7 +770,8 @@ func isUnique_native(_ ref: inout Builtin.BridgeObject) -> Bool {
760770
// BridgeObject pinned nonNull native
761771
// CHECK-LABEL: sil hidden @_T08builtins23isUniqueOrPinned_native{{[_0-9a-zA-Z]*}}F
762772
// CHECK: bb0(%0 : $*Builtin.BridgeObject):
763-
// CHECK: [[CAST:%.*]] = unchecked_addr_cast %0 : $*Builtin.BridgeObject to $*Builtin.NativeObject
773+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] %0
774+
// CHECK: [[CAST:%.*]] = unchecked_addr_cast [[WRITE]] : $*Builtin.BridgeObject to $*Builtin.NativeObject
764775
// CHECK: [[BUILTIN:%.*]] = is_unique_or_pinned [[CAST]] : $*Builtin.NativeObject
765776
// CHECK: return
766777
func isUniqueOrPinned_native(_ ref: inout Builtin.BridgeObject) -> Bool {

test/SILGen/cf_members.swift

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,20 @@ public func foo(_ x: Double) {
5151
// z = b(x)
5252

5353
// CHECK: [[FN:%.*]] = function_ref @IAMStruct1InvertInPlace
54-
// CHECK: apply [[FN]]([[Z]])
54+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] [[Z]] : $*Struct1
55+
// CHECK: apply [[FN]]([[WRITE]])
5556
z.invert()
5657

5758
// CHECK: [[FN:%.*]] = function_ref @IAMStruct1Rotate : $@convention(c) (@in Struct1, Double) -> Struct1
58-
// CHECK: [[ZVAL:%.*]] = load [trivial] [[Z]]
59+
// CHECK: [[WRITE:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
60+
// CHECK: [[ZVAL:%.*]] = load [trivial] [[WRITE]]
5961
// CHECK: store [[ZVAL]] to [trivial] [[ZTMP:%.*]] :
6062
// CHECK: apply [[FN]]([[ZTMP]], [[X]])
6163
z = z.translate(radians: x)
6264

6365
// CHECK: [[THUNK:%.*]] = function_ref [[THUNK_NAME:@_T0SC7Struct1V9translateABSd7radians_tFTcTO]]
64-
// CHECK: [[ZVAL:%.*]] = load [trivial] [[Z]]
66+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
67+
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
6568
// CHECK: [[C:%.*]] = apply [[THUNK]]([[ZVAL]])
6669
// CHECK: [[BORROWED_C:%.*]] = begin_borrow [[C]]
6770
// CHECK: [[C_COPY:%.*]] = copy_value [[BORROWED_C]]
@@ -82,12 +85,14 @@ public func foo(_ x: Double) {
8285
// z = e(z, x)
8386

8487
// CHECK: [[FN:%.*]] = function_ref @IAMStruct1Scale
85-
// CHECK: [[ZVAL:%.*]] = load [trivial] [[Z]]
88+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
89+
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
8690
// CHECK: apply [[FN]]([[ZVAL]], [[X]])
8791
z = z.scale(x)
8892

8993
// CHECK: [[THUNK:%.*]] = function_ref @_T0SC7Struct1V5scaleABSdFTcTO
90-
// CHECK: [[ZVAL:%.*]] = load [trivial] [[Z]]
94+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
95+
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
9196
// CHECK: [[F:%.*]] = apply [[THUNK]]([[ZVAL]])
9297
// CHECK: [[BORROWED_F:%.*]] = begin_borrow [[F]]
9398
// CHECK: [[F_COPY:%.*]] = copy_value [[BORROWED_F]]
@@ -98,33 +103,39 @@ public func foo(_ x: Double) {
98103
// CHECK: [[THUNK:%.*]] = function_ref @_T0SC7Struct1V5scaleABSdFTcTO
99104
// CHECK: thin_to_thick_function [[THUNK]]
100105
let g = Struct1.scale
101-
// CHECK: [[ZVAL:%.*]] = load [trivial] [[Z]]
106+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
107+
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
102108
z = g(z)(x)
103109

104110
// TODO: If we implement SE-0042, this should directly reference the
105111
// underlying C function.
106112
// let h: @convention(c) (Struct1, Double) -> Struct1 = Struct1.scale
107113
// z = h(z, x)
108114

109-
// CHECK: [[ZVAL:%.*]] = load [trivial] [[Z]]
115+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
116+
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
110117
// CHECK: store [[ZVAL]] to [trivial] [[ZTMP:%.*]] :
111118
// CHECK: [[GET:%.*]] = function_ref @IAMStruct1GetRadius : $@convention(c) (@in Struct1) -> Double
112119
// CHECK: apply [[GET]]([[ZTMP]])
113120
_ = z.radius
114-
// CHECK: [[ZVAL:%.*]] = load [trivial] [[Z]]
121+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
122+
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
115123
// CHECK: [[SET:%.*]] = function_ref @IAMStruct1SetRadius : $@convention(c) (Struct1, Double) -> ()
116124
// CHECK: apply [[SET]]([[ZVAL]], [[X]])
117125
z.radius = x
118126

119-
// CHECK: [[ZVAL:%.*]] = load [trivial] [[Z]]
127+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
128+
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
120129
// CHECK: [[GET:%.*]] = function_ref @IAMStruct1GetAltitude : $@convention(c) (Struct1) -> Double
121130
// CHECK: apply [[GET]]([[ZVAL]])
122131
_ = z.altitude
132+
// CHECK: [[WRITE:%.*]] = begin_access [modify] [unknown] [[Z]] : $*Struct1
123133
// CHECK: [[SET:%.*]] = function_ref @IAMStruct1SetAltitude : $@convention(c) (@inout Struct1, Double) -> ()
124-
// CHECK: apply [[SET]]([[Z]], [[X]])
134+
// CHECK: apply [[SET]]([[WRITE]], [[X]])
125135
z.altitude = x
126136

127-
// CHECK: [[ZVAL:%.*]] = load [trivial] [[Z]]
137+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
138+
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
128139
// CHECK: [[GET:%.*]] = function_ref @IAMStruct1GetMagnitude : $@convention(c) (Struct1) -> Double
129140
// CHECK: apply [[GET]]([[ZVAL]])
130141
_ = z.magnitude
@@ -173,7 +184,8 @@ public func foo(_ x: Double) {
173184
_ = makeMetatype().getOnlyProperty
174185

175186
// CHECK: [[FN:%.*]] = function_ref @IAMStruct1SelfComesLast : $@convention(c) (Double, Struct1) -> ()
176-
// CHECK: [[ZVAL:%.*]] = load [trivial] [[Z]]
187+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
188+
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
177189
// CHECK: apply [[FN]]([[X]], [[ZVAL]])
178190
z.selfComesLast(x: x)
179191
let k: (Double) -> () = z.selfComesLast(x:)
@@ -186,7 +198,8 @@ public func foo(_ x: Double) {
186198
// m(z, x)
187199

188200
// CHECK: [[FN:%.*]] = function_ref @IAMStruct1SelfComesThird : $@convention(c) (Int32, Float, Struct1, Double) -> ()
189-
// CHECK: [[ZVAL:%.*]] = load [trivial] [[Z]]
201+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[Z]] : $*Struct1
202+
// CHECK: [[ZVAL:%.*]] = load [trivial] [[READ]]
190203
// CHECK: apply [[FN]]({{.*}}, {{.*}}, [[ZVAL]], [[X]])
191204
z.selfComesThird(a: y, b: 0, x: x)
192205
let n: (Int32, Float, Double) -> () = z.selfComesThird(a:b:x:)

test/SILGen/class_bound_protocols.swift

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ func class_bound_generic<T : ClassBound>(x: T) -> T {
3232
// CHECK: [[X_COPY:%.*]] = copy_value [[BORROWED_X]]
3333
// CHECK: store [[X_COPY]] to [init] [[PB]]
3434
return x
35-
// CHECK: [[X1:%.*]] = load [copy] [[PB]]
35+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[PB]] : $*T
36+
// CHECK: [[X1:%.*]] = load [copy] [[READ]]
3637
// CHECK: destroy_value [[X_ADDR]]
3738
// CHECK: destroy_value [[X]]
3839
// CHECK: return [[X1]]
@@ -49,7 +50,8 @@ func class_bound_generic_2<T : ClassBound & NotClassBound>(x: T) -> T {
4950
// CHECK: store [[X_COPY]] to [init] [[PB]]
5051
// CHECK: end_borrow [[BORROWED_X]] from [[X]]
5152
return x
52-
// CHECK: [[X1:%.*]] = load [copy] [[PB]]
53+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[PB]] : $*T
54+
// CHECK: [[X1:%.*]] = load [copy] [[READ]]
5355
// CHECK: return [[X1]]
5456
}
5557

@@ -64,7 +66,8 @@ func class_bound_protocol(x: ClassBound) -> ClassBound {
6466
// CHECK: store [[X_COPY]] to [init] [[PB]]
6567
// CHECK: end_borrow [[BORROWED_X]] from [[X]]
6668
return x
67-
// CHECK: [[X1:%.*]] = load [copy] [[PB]]
69+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[PB]] : $*ClassBound
70+
// CHECK: [[X1:%.*]] = load [copy] [[READ]]
6871
// CHECK: return [[X1]]
6972
}
7073

@@ -80,7 +83,8 @@ func class_bound_protocol_composition(x: ClassBound & NotClassBound)
8083
// CHECK: store [[X_COPY]] to [init] [[PB]]
8184
// CHECK: end_borrow [[BORROWED_X]] from [[X]]
8285
return x
83-
// CHECK: [[X1:%.*]] = load [copy] [[PB]]
86+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[PB]] : $*ClassBound & NotClassBound
87+
// CHECK: [[X1:%.*]] = load [copy] [[READ]]
8488
// CHECK: return [[X1]]
8589
}
8690

@@ -131,7 +135,8 @@ func class_bound_method(x: ClassBound) {
131135
// CHECK: [[ARG_COPY:%.*]] = copy_value [[BORROWED_ARG]]
132136
// CHECK: store [[ARG_COPY]] to [init] [[XBOX_PB]]
133137
// CHECK: end_borrow [[BORROWED_ARG]] from [[ARG]]
134-
// CHECK: [[X:%.*]] = load [copy] [[XBOX_PB]] : $*ClassBound
138+
// CHECK: [[READ:%.*]] = begin_access [read] [unknown] [[XBOX_PB]] : $*ClassBound
139+
// CHECK: [[X:%.*]] = load [copy] [[READ]] : $*ClassBound
135140
// CHECK: [[PROJ:%.*]] = open_existential_ref [[X]] : $ClassBound to $[[OPENED:@opened(.*) ClassBound]]
136141
// CHECK: [[METHOD:%.*]] = witness_method $[[OPENED]], #ClassBound.classBoundMethod!1
137142
// CHECK: apply [[METHOD]]<[[OPENED]]>([[PROJ]])

0 commit comments

Comments
 (0)