SwiftCompilerSources: improve APIs for UseList

Make filter APIs for UseList chainable by adding them to Sequence where Element == Operand

For example, it allows to write:
```
let singleUse = value.uses.ignoreDebugUses.ignoreUsers(ofType: EndAccessInst.self).singleUse
```

Also, add `UseList.getSingleUser(notOfType:)`
This commit is contained in:
Erik Eckstein
2023-10-20 14:16:26 +02:00
parent eb597cb6d8
commit 0509a056fb
10 changed files with 54 additions and 95 deletions

View File

@@ -365,9 +365,7 @@ private struct StackProtectionOptimization {
let builder = Builder(after: beginAccess, location: beginAccess.location.autoGenerated, context)
let temporary = builder.createAllocStack(beginAccess.type)
for use in beginAccess.uses where !(use.instruction is EndAccessInst) {
use.instruction.setOperand(at: use.index, to: temporary, context)
}
beginAccess.uses.ignoreUsers(ofType: EndAccessInst.self).replaceAll(with: temporary, context)
for endAccess in beginAccess.endInstructions {
let endBuilder = Builder(before: endAccess, location: endAccess.location.autoGenerated, context)