File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities
test/SILOptimizer/lifetime_dependence Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -464,6 +464,8 @@ extension LifetimeDependence.Scope {
464
464
range. insert ( inst)
465
465
case let li as LoadInst where li. loadOwnership == . take:
466
466
range. insert ( inst)
467
+ case is EndBorrowInst :
468
+ range. insert ( inst)
467
469
default :
468
470
break
469
471
}
Original file line number Diff line number Diff line change @@ -29,8 +29,13 @@ struct NEObject : ~Escapable {
29
29
init()
30
30
}
31
31
32
+ public struct Holder {
33
+ var c: C
34
+ }
35
+
32
36
sil @makeNE : $@convention(thin) () -> @lifetime(immortal) @owned NE
33
37
sil @makeNEObject : $@convention(thin) () -> @lifetime(immortal) @owned NEObject
38
+ sil @useNE : $@convention(thin) (NE) -> ()
34
39
35
40
// Test returning a owned dependence on a trivial value
36
41
sil [ossa] @return_trivial_dependence : $@convention(thin) (@guaranteed C) -> @lifetime(borrow 0) @owned NE {
@@ -55,3 +60,23 @@ entry(%0 : @guaranteed $C):
55
60
%mark = mark_dependence [unresolved] %call : $NEObject on %zero : $Builtin.Int1
56
61
return %mark // expected-note {{this use causes the lifetime-dependent value to escape}}
57
62
}
63
+
64
+ // OK: Test that the range initialized by a store_borrow covers dependent uses.
65
+ sil [ossa] @testStoreBorrowRange : $@convention(thin) (@owned Holder) -> () {
66
+ bb0(%0 : @owned $Holder):
67
+ %val = move_value [lexical] [var_decl] %0
68
+ %stk = alloc_stack $Holder
69
+ %sb = store_borrow %val to %stk
70
+ %f1 = function_ref @makeNE : $@convention(thin) () -> @lifetime(immortal) @owned NE
71
+ %c1 = apply %f1() : $@convention(thin) () -> @lifetime(immortal) @owned NE
72
+ %md = mark_dependence [unresolved] %c1 on %sb
73
+ %mv = move_value [var_decl] %md
74
+ %f2 = function_ref @useNE : $@convention(thin) (NE) -> ()
75
+ %c2 = apply %f2(%mv) : $@convention(thin) (NE) -> ()
76
+ destroy_value %mv
77
+ end_borrow %sb
78
+ dealloc_stack %stk
79
+ destroy_value %val
80
+ %99 = tuple ()
81
+ return %99
82
+ }
You can’t perform that action at this time.
0 commit comments