@@ -64,7 +64,8 @@ sil @getNEPointerToA : $@convention(thin) (@guaranteed NE) -> UnsafePointer<A>
64
64
sil @useA : $@convention(thin) (A) -> ()
65
65
66
66
sil @getPtr : $@convention(thin) () -> @out UnsafeRawPointer
67
- sil @getSpan : $@convention(thin) (@in_guaranteed AnyObject) -> @lifetime(borrow 0) @out NE
67
+
68
+ sil @getOwnedNE : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE
68
69
69
70
sil @useNE : $@convention(thin) (@guaranteed NE) -> ()
70
71
@@ -439,3 +440,43 @@ bb0(%0 : @owned $B):
439
440
%24 = tuple ()
440
441
return %24
441
442
}
443
+
444
+ // =============================================================================
445
+ // Return value extension
446
+ // =============================================================================
447
+
448
+ // Sink the end access to the "return" phi and rewrite mark_dependence on the argument.
449
+ //
450
+ // CHECK-LABEL: sil hidden [ossa] @testReturnPhi : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned Optional<NE> {
451
+ // CHECK: bb0(%0 : $*Holder):
452
+ // CHECK: bb1:
453
+ // CHECK: enum $Optional<NE>, #Optional.none!enumelt
454
+ // CHECK: bb2:
455
+ // CHECK: [[ACCESS:%.*]] = begin_access [modify] [unknown] %0
456
+ // CHECK: [[MD:%.*]] = mark_dependence [unresolved] {{%.*}} on %0
457
+ // CHECK: [[OPT:%.*]] = enum $Optional<NE>, #Optional.some!enumelt, %7
458
+ // CHECK: end_access [[ACCESS]]
459
+ // CHECK: br bb3([[OPT]])
460
+ // CHECK: bb3([[RET:%.*]] : @owned $Optional<NE>):
461
+ // CHECK: return [[RET]]
462
+ // CHECK-LABEL: } // end sil function 'testReturnPhi'
463
+ sil hidden [ossa] @testReturnPhi : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned Optional<NE> {
464
+ bb0(%0 : $*Holder):
465
+ cond_br undef, bb1, bb2
466
+
467
+ bb1:
468
+ %none = enum $Optional<NE>, #Optional.none!enumelt
469
+ br bb3(%none)
470
+
471
+ bb2:
472
+ %access = begin_access [modify] [unknown] %0
473
+ %f = function_ref @getOwnedNE : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE
474
+ %ne = apply %f(%access) : $@convention(thin) (@inout Holder) -> @lifetime(borrow 0) @owned NE
475
+ %md = mark_dependence [unresolved] %ne on %access
476
+ end_access %access
477
+ %some = enum $Optional<NE>, #Optional.some!enumelt, %md
478
+ br bb3(%some)
479
+
480
+ bb3(%ret : @owned $Optional<NE>):
481
+ return %ret
482
+ }
0 commit comments