@@ -63,14 +63,16 @@ func nestedNoEscape(f: inout Frob) {
63
63
// Allow aliased noescape reads.
64
64
func readRead( ) {
65
65
var x = 3
66
- // Around the call: [read] [dynamic ]
66
+ // Around the call: [read] [static ]
67
67
// Inside each closure: [read] [static]
68
68
doTwo ( { _ = x } , { _ = x } )
69
69
x = 42
70
70
}
71
71
// CHECK-LABEL: sil hidden @_T027access_enforcement_noescape8readReadyyF : $@convention(thin) () -> () {
72
72
// CHECK: [[ALLOC:%.*]] = alloc_stack $Int, var, name "x"
73
- // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [read] [dynamic] [[ALLOC]] : $*Int
73
+ // CHECK-NOT: begin_access [read] [dynamic]
74
+ // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [read] [static] [[ALLOC]] : $*Int
75
+ // CHECK-NOT: begin_access [read] [dynamic]
74
76
// CHECK: apply
75
77
// FIXME-CHECK: end_access [[ACCESS]]
76
78
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape8readReadyyF'
@@ -121,18 +123,15 @@ func inoutReadRead(x: inout Int) {
121
123
func readBoxRead( ) {
122
124
var x = 3
123
125
let c = { _ = x }
124
- // Around the call: [read] [dynamic]
125
126
// Inside may-escape closure `c`: [read] [dynamic]
126
- // Inside never-escape closure: [read] [static ]
127
+ // Inside never-escape closure: [read] [dynamic ]
127
128
doTwo ( c, { _ = x } )
128
129
x = 42
129
130
}
130
131
// CHECK-LABEL: sil hidden @_T027access_enforcement_noescape11readBoxReadyyF : $@convention(thin) () -> () {
131
132
// CHECK: [[PA1:%.*]] = partial_apply
132
133
// CHECK: [[PA2:%.*]] = partial_apply
133
- // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [read] [dynamic] %0 : $*Int
134
134
// CHECK: apply %{{.*}}([[PA1]], [[PA2]])
135
- // FIXME-CHECK: end_access [[ACCESS]]
136
135
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape11readBoxReadyyF'
137
136
138
137
// closure #1 in readBoxRead()
@@ -144,8 +143,9 @@ func readBoxRead() {
144
143
145
144
// closure #2 in readBoxRead()
146
145
// CHECK-LABEL: sil private @_T027access_enforcement_noescape11readBoxReadyyFyycfU0_ : $@convention(thin) (@inout_aliasable Int) -> () {
147
- // CHECK-NOT: [[ACCESS:%.*]] = begin_access [read] [dynamic]
148
- // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [read] [static] %0 : $*Int
146
+ // FIXME-CHECK-LABEL: sil private @_T027access_enforcement_noescape11readBoxReadyyFyycfU0_ : $@convention(thin) (@owned { var Int }) -> () {
147
+ // FIXME-CHECK: [[ADDR:%.*]] = project_box %0 : ${ var Int }, 0
148
+ // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [read] [dynamic] [[ADDR]] : $*Int
149
149
// FIXME-CHECK: end_access [[ACCESS]]
150
150
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape11readBoxReadyyFyycfU0_'
151
151
@@ -159,15 +159,15 @@ func readBoxRead() {
159
159
// Allow aliased noescape read + write.
160
160
func readWrite( ) {
161
161
var x = 3
162
- // Around the call: [modify] [dynamic ]
162
+ // Around the call: [modify] [static ]
163
163
// Inside closure 1: [read] [static]
164
164
// Inside closure 2: [modify] [static]
165
165
doTwo ( { _ = x } , { x = 42 } )
166
166
}
167
167
// CHECK-LABEL: sil hidden @_T027access_enforcement_noescape9readWriteyyF : $@convention(thin) () -> () {
168
168
// CHECK: [[PA1:%.*]] = partial_apply
169
169
// CHECK: [[PA2:%.*]] = partial_apply
170
- // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic ] %0 : $*Int
170
+ // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [modify] [static ] %0 : $*Int
171
171
// CHECK: apply %{{.*}}([[PA1]], [[PA2]])
172
172
// FIXME-CHECK: end_access [[ACCESS]]
173
173
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape9readWriteyyF'
@@ -227,17 +227,15 @@ func inoutReadWrite(x: inout Int) {
227
227
func readBoxWrite( ) {
228
228
var x = 3
229
229
let c = { _ = x }
230
- // Around the call: [modify] [dynamic]
231
230
// Inside may-escape closure `c`: [read] [dynamic]
232
- // Inside never-escape closure: [modify] [static ]
231
+ // Inside never-escape closure: [modify] [dynamic ]
233
232
doTwo ( c, { x = 42 } )
234
233
}
235
234
// CHECK-LABEL: sil hidden @_T027access_enforcement_noescape12readBoxWriteyyF : $@convention(thin) () -> () {
236
235
// CHECK: [[PA1:%.*]] = partial_apply
237
236
// CHECK: [[PA2:%.*]] = partial_apply
238
- // FIXME- CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic] %0 : $*Int
237
+ // CHECK-NOT: begin_access
239
238
// CHECK: apply %{{.*}}([[PA1]], [[PA2]])
240
- // FIXME-CHECK: end_access [[ACCESS]]
241
239
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape12readBoxWriteyyF'
242
240
243
241
// closure #1 in readBoxWrite()
@@ -249,8 +247,9 @@ func readBoxWrite() {
249
247
250
248
// closure #2 in readBoxWrite()
251
249
// CHECK-LABEL: sil private @_T027access_enforcement_noescape12readBoxWriteyyFyycfU0_ : $@convention(thin) (@inout_aliasable Int) -> () {
252
- // CHECK-NOT: [[ACCESS:%.*]] = begin_access [modify] [dynamic]
253
- // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [modify] [static] %0 : $*Int
250
+ // FIXME-CHECK-LABEL: sil private @_T027access_enforcement_noescape12readBoxWriteyyFyycfU0_ : $@convention(thin) (@owned { var Int }) -> () {
251
+ // FIXME-CHECK: [[ADDR:%.*]] = project_box %0 : ${ var Int }, 0
252
+ // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [read] [dynamic] [[ADDR]] : $*Int
254
253
// FIXME-CHECK: end_access [[ACCESS]]
255
254
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape12readBoxWriteyyFyycfU0_'
256
255
@@ -266,18 +265,16 @@ func readBoxWrite() {
266
265
func readWriteBox( ) {
267
266
var x = 3
268
267
let c = { x = 42 }
269
- // Around the call: [read] [dynamic]
270
268
// Inside may-escape closure `c`: [modify] [dynamic]
271
- // Inside never-escape closure: [read] [static ]
269
+ // Inside never-escape closure: [read] [dynamic ]
272
270
doTwo ( { _ = x } , c)
273
271
}
274
272
275
273
// CHECK-LABEL: sil hidden @_T027access_enforcement_noescape12readWriteBoxyyF : $@convention(thin) () -> () {
276
274
// CHECK: [[PA1:%.*]] = partial_apply
277
275
// CHECK: [[PA2:%.*]] = partial_apply
278
- // FIXME- CHECK: [[ACCESS:%.*]] = begin_access [read] [dynamic] %0 : $*Int
276
+ // CHECK-NOT: begin_access
279
277
// CHECK: apply %{{.*}}([[PA2]], [[PA1]])
280
- // FIXME-CHECK: end_access [[ACCESS]]
281
278
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape12readWriteBoxyyF'
282
279
283
280
// closure #1 in readWriteBox()
@@ -289,8 +286,9 @@ func readWriteBox() {
289
286
290
287
// closure #2 in readWriteBox()
291
288
// CHECK-LABEL: sil private @_T027access_enforcement_noescape12readWriteBoxyyFyycfU0_ : $@convention(thin) (@inout_aliasable Int) -> () {
292
- // CHECK-NOT: [[ACCESS:%.*]] = begin_access [read] [dynamic]
293
- // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [read] [static] %0 : $*Int
289
+ // FIXME-CHECK-LABEL: sil private @_T027access_enforcement_noescape12readWriteBoxyyFyycfU0_ : $@convention(thin) ((@owned { var Int }) -> () {
290
+ // FIXME-CHECK: [[ADDR:%.*]] = project_box %0 : ${ var Int }, 0
291
+ // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic] [[ADDR]] : $*Int
294
292
// FIXME-CHECK: end_access [[ACCESS]]
295
293
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape12readWriteBoxyyFyycfU0_'
296
294
@@ -303,15 +301,15 @@ func readWriteBox() {
303
301
// Error: noescape read + write inout.
304
302
func readWriteInout( ) {
305
303
var x = 3
306
- // Around the call: [read] [dynamic ]
304
+ // Around the call: [read] [static ]
307
305
// Around the call: [modify] [static] // Error
308
306
// Inside closure: [modify] [static]
309
307
doOneInout ( { _ = x } , & x)
310
308
}
311
309
312
310
// CHECK-LABEL: sil hidden @_T027access_enforcement_noescape14readWriteInoutyyF : $@convention(thin) () -> () {
313
311
// CHECK: [[PA1:%.*]] = partial_apply
314
- // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [read] [dynamic ] %0 : $*Int
312
+ // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [read] [static ] %0 : $*Int
315
313
// FIXME-CHECK: [[ACCESS2:%.*]] = begin_access [modify] [static] %0 : $*Int
316
314
// FIXME-CHECK: apply %{{.*}}([[PA1]], [[ACCESS2]])
317
315
// FIXME-CHECK: end_access [[ACCESS2]]
@@ -350,6 +348,7 @@ func inoutReadWriteInout(x: inout Int) {
350
348
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape19inoutReadWriteInoutySiz1x_tFyycfU_'
351
349
352
350
// Trap on boxed read + write inout.
351
+ // FIXME: Passing a captured var as inout needs dynamic enforcement.
353
352
func readBoxWriteInout( ) {
354
353
var x = 3
355
354
let c = { _ = x }
@@ -381,7 +380,7 @@ func readBoxWriteInout() {
381
380
// Allow aliased noescape write + write.
382
381
func writeWrite( ) {
383
382
var x = 3
384
- // Around the call: [modify] [dynamic ]
383
+ // Around the call: [modify] [static ]
385
384
// Inside closure 1: [modify] [static]
386
385
// Inside closure 2: [modify] [static]
387
386
doTwo ( { x = 42 } , { x = 87 } )
@@ -391,7 +390,7 @@ func writeWrite() {
391
390
// CHECK-LABEL: sil hidden @_T027access_enforcement_noescape10writeWriteyyF : $@convention(thin) () -> () {
392
391
// CHECK: [[PA1:%.*]] = partial_apply
393
392
// CHECK: [[PA2:%.*]] = partial_apply
394
- // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic ] %0 : $*Int
393
+ // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [modify] [static ] %0 : $*Int
395
394
// FIXME-CHECK: apply %{{.*}}([[PA1]], [[PA2]])
396
395
// FIXME-CHECK: end_access [[ACCESS]]
397
396
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape10writeWriteyyF'
@@ -447,19 +446,17 @@ func inoutWriteWrite(x: inout Int) {
447
446
func writeWriteBox( ) {
448
447
var x = 3
449
448
let c = { x = 87 }
450
- // Around the call: [modify] [dynamic]
451
449
// Inside may-escape closure `c`: [modify] [dynamic]
452
- // Inside never-escape closure: [modify] [static ]
450
+ // Inside never-escape closure: [modify] [dynamic ]
453
451
doTwo ( { x = 42 } , c)
454
452
_ = x
455
453
}
456
454
457
455
// CHECK-LABEL: sil hidden @_T027access_enforcement_noescape13writeWriteBoxyyF : $@convention(thin) () -> () {
458
456
// CHECK: [[PA1:%.*]] = partial_apply
459
457
// CHECK: [[PA2:%.*]] = partial_apply
460
- // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic] %0 : $*Int
458
+ // FIXME-CHECK-NOT: begin_access
461
459
// FIXME-CHECK: apply %{{.*}}([[PA1]], [[PA2]])
462
- // FIXME-CHECK: end_access [[ACCESS]]
463
460
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape13writeWriteBoxyyF'
464
461
465
462
// closure #1 in writeWriteBox()
@@ -471,8 +468,8 @@ func writeWriteBox() {
471
468
472
469
// closure #2 in writeWriteBox()
473
470
// CHECK-LABEL: sil private @_T027access_enforcement_noescape13writeWriteBoxyyFyycfU0_ : $@convention(thin) (@inout_aliasable Int) -> () {
474
- // CHECK-NOT : [[ACCESS :%.*]] = begin_access [modify] [dynamic]
475
- // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [modify] [static] %0 : $*Int
471
+ // FIXME-CHECK : [[ADDR :%.*]] = project_box %0 : ${ var Int }, 0
472
+ // FIXME-CHECK: [[ACCESS:%.*]] = begin_access [modify] [dynamic] [[ADDR]] : $*Int
476
473
// FIXME-CHECK: end_access [[ACCESS]]
477
474
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape13writeWriteBoxyyFyycfU0_'
478
475
@@ -482,21 +479,22 @@ func writeWriteBox() {
482
479
// doTwo({ x = 42 }, c)
483
480
// }
484
481
485
- /// Error: on noescape write + write inout.
482
+ // Error: on noescape write + write inout.
486
483
func writeWriteInout( ) {
487
484
var x = 3
488
- // Around the call: [modify] [dynamic ]
485
+ // Around the call: [modify] [static ]
489
486
// Around the call: [modify] [static] // Error
490
487
// Inside closure: [modify] [static]
491
488
doOneInout ( { x = 42 } , & x)
492
489
}
493
490
494
491
// CHECK-LABEL: sil hidden @_T027access_enforcement_noescape15writeWriteInoutyyF : $@convention(thin) () -> () {
495
492
// CHECK: [[PA1:%.*]] = partial_apply
496
- // FIXME-CHECK: [[ACCESS :%.*]] = begin_access [modify] [dynamic ] %0 : $*Int
493
+ // FIXME-CHECK: [[ACCESS1 :%.*]] = begin_access [modify] [static ] %0 : $*Int
497
494
// FIXME-CHECK: [[ACCESS2:%.*]] = begin_access [modify] [static] %0 : $*Int
498
495
// FIXME-CHECK: apply %{{.*}}([[PA1]], [[ACCESS2]])
499
- // FIXME-CHECK: end_access [[ACCESS]]
496
+ // FIXME-CHECK: end_access [[ACCESS2]]
497
+ // FIXME-CHECK: end_access [[ACCESS1]]
500
498
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape15writeWriteInoutyyF'
501
499
502
500
// closure #1 in writeWriteInout()
@@ -531,6 +529,7 @@ func inoutWriteWriteInout(x: inout Int) {
531
529
// CHECK-LABEL: } // end sil function '_T027access_enforcement_noescape010inoutWriteE5InoutySiz1x_tFyycfU_'
532
530
533
531
// Trap on boxed write + write inout.
532
+ // FIXME: Passing a captured var as inout needs dynamic enforcement.
534
533
func writeBoxWriteInout( ) {
535
534
var x = 3
536
535
let c = { x = 42 }
0 commit comments