Skip to content

Commit e1e23e2

Browse files
committed
Add Value.isForwarded(from:)
A simple utility on ForwardingInstructions that should be defined alongside similar utilities rather than inside a pass.
1 parent 9f66949 commit e1e23e2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

SwiftCompilerSources/Sources/SIL/ForwardingInstruction.swift

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ extension Value {
7373
}
7474
}
7575

76+
extension Value {
77+
public func isForwarded(from: Value) -> Bool {
78+
if self == from {
79+
return true
80+
}
81+
if let forward = self.forwardingInstruction,
82+
let singleOp = forward.singleForwardedOperand {
83+
return singleOp.value.isForwarded(from: from)
84+
}
85+
return false
86+
}
87+
}
88+
7689
//===----------------------------------------------------------------------===//
7790
// singleForwardedOperand
7891
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)