@@ -65,7 +65,8 @@ sil @useA : $@convention(thin) (A) -> ()
65
65
66
66
sil @getPtr : $@convention(thin) () -> @out UnsafeRawPointer
67
67
68
- sil @getOwnedNE : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE
68
+ sil @getOwnedNE : $@convention(thin) (@guaranteed Holder) -> @lifetime(borrow 0) @owned NE
69
+ sil @getOwnedNEFromInout : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE
69
70
70
71
sil @useNE : $@convention(thin) (@guaranteed NE) -> ()
71
72
470
471
471
472
bb2:
472
473
%access = begin_access [modify] [unknown] %0
473
- %f = function_ref @getOwnedNE : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE
474
+ %f = function_ref @getOwnedNEFromInout : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE
474
475
%ne = apply %f(%access) : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE
475
476
%md = mark_dependence [unresolved] %ne on %access
476
477
end_access %access
@@ -480,3 +481,26 @@ bb2:
480
481
bb3(%ret : @owned $Optional<NE>):
481
482
return %ret
482
483
}
484
+
485
+ // Allow a [read] access to depend on a caller's [modify] access.
486
+ //
487
+ // CHECK-LABEL: sil hidden [noinline] [ossa] @testNestedModRead : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE {
488
+ // CHECK: bb0(%0 : $*Holder):
489
+ // CHECK: [[ACCESS:%.*]] = begin_access [read] [unknown] %0
490
+ // CHECK: [[LD:%.*]] = load [copy] [[ACCESS]]
491
+ // CHECK: [[MD:%.*]] = mark_dependence [unresolved] %{{.*}} on %0
492
+ // CHECK: destroy_value [[LD]]
493
+ // CHECK: end_access [[ACCESS]]
494
+ // CHECK: return [[MD]]
495
+ // CHECK-LABEL: } // end sil function 'testNestedModRead'
496
+ sil hidden [noinline] [ossa] @testNestedModRead : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE {
497
+ bb0(%0 : $*Holder):
498
+ %access = begin_access [read] [unknown] %0
499
+ %holder = load [copy] %access
500
+ end_access %access
501
+ %f = function_ref @getOwnedNE : $@convention(thin) (@guaranteed Holder) -> @lifetime(borrow 0) @owned NE
502
+ %ne = apply %f(%holder) : $@convention(thin) (@guaranteed Holder) -> @lifetime(borrow 0) @owned NE
503
+ %md = mark_dependence [unresolved] %ne on %access
504
+ destroy_value %holder
505
+ return %md
506
+ }
0 commit comments