Skip to content

Commit f69dfe4

Browse files
committed
Add OperandOwnership.endsLifetime
And rename `uses.lifetimeEndingUses` to `uses.endingLifetime`
1 parent d8b9010 commit f69dfe4

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

SwiftCompilerSources/Sources/SIL/Operand.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ extension Sequence where Element == Operand {
154154
ignoreUsers(ofType: I.self).singleUse?.instruction
155155
}
156156

157-
public var lifetimeEndingUses: LazyFilterSequence<Self> {
157+
public var endingLifetime: LazyFilterSequence<Self> {
158158
return self.lazy.filter { $0.endsLifetime }
159159
}
160160
}
@@ -218,6 +218,17 @@ public enum OperandOwnership {
218218
/// Reborrow. Ends the borrow scope opened directly by the operand and begins one or multiple disjoint borrow scopes. If a forwarded value is reborrowed, then its base must also be reborrowed at the same point. (br, FIXME: should also include destructure, tuple, struct)
219219
case reborrow
220220

221+
public var endsLifetime: Bool {
222+
switch self {
223+
case .nonUse, .trivialUse, .instantaneousUse, .unownedInstantaneousUse,
224+
.forwardingUnowned, .pointerEscape, .bitwiseEscape, .borrow,
225+
.interiorPointer, .guaranteedForwarding:
226+
return false
227+
case .destroyingConsume, .forwardingConsume, .endBorrow, .reborrow:
228+
return true
229+
}
230+
}
231+
221232
public var _bridged: BridgedOperand.OperandOwnership {
222233
switch self {
223234
case .nonUse:

0 commit comments

Comments
 (0)