File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
SwiftCompilerSources/Sources/Optimizer/Utilities Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -131,6 +131,25 @@ enum AccessBase : CustomStringConvertible, Hashable {
131
131
return nil
132
132
}
133
133
}
134
+
135
+ /// True if this access base may be derived from a reference that is only valid within a locally
136
+ /// scoped OSSA lifetime. For example:
137
+ ///
138
+ /// %reference = begin_borrow %1
139
+ /// %base = ref_tail_addr %reference <- %base must not be used outside the borrow scope
140
+ /// end_borrow %reference
141
+ ///
142
+ /// This is not true for scoped storage such as alloc_stack and @in arguments.
143
+ ///
144
+ var hasLocalOwnershipLifetime : Bool {
145
+ if let reference = reference {
146
+ // Conservatively assume that everything which is a ref-counted object is within an ownership scope.
147
+ // TODO: we could e.g. exclude guaranteed function arguments.
148
+ return reference. ownership != . none
149
+ }
150
+ return false
151
+ }
152
+
134
153
/// True, if the baseAddress is of an immutable property or global variable
135
154
var isLet : Bool {
136
155
switch self {
You can’t perform that action at this time.
0 commit comments