Skip to content

Commit 7c71f00

Browse files
committed
Swift SIL: add UseList.isSingleUse
1 parent dd5d5f9 commit 7c71f00

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

SwiftCompilerSources/Sources/SIL/Operand.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,16 @@ public struct UseList : CollectionLikeSequence {
9999
self.firstOpPtr = firstOpPtr.op
100100
}
101101

102-
public var isSingleUse: Bool {
102+
public var singleUse: Operand? {
103103
if let opPtr = firstOpPtr {
104-
return Operand_nextUse(BridgedOperand(op: opPtr)).op == nil
104+
if Operand_nextUse(BridgedOperand(op: opPtr)).op != nil { return nil }
105+
return Operand(BridgedOperand(op: opPtr))
105106
}
106-
return false
107+
return nil
107108
}
108109

110+
public var isSingleUse: Bool { singleUse != nil }
111+
109112
public func makeIterator() -> Iterator {
110113
return Iterator(currentOpPtr: firstOpPtr)
111114
}

0 commit comments

Comments
 (0)