mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
SIL: be more tolerant when a user is deleted during use-list iteration.
Check if an operand's instruction has been deleted in `UseList.next()`. This allows to delete an instruction, which has two uses of a value, during use-list iteration.
This commit is contained in:
@@ -105,8 +105,16 @@ public struct UseList : CollectionLikeSequence {
|
||||
var currentOpPtr: OptionalBridgedOperand
|
||||
|
||||
public mutating func next() -> Operand? {
|
||||
if let op = currentOpPtr.operand {
|
||||
currentOpPtr = op.getNextUse()
|
||||
if let bridgedOp = currentOpPtr.operand {
|
||||
var op = bridgedOp
|
||||
// Skip operands of deleted instructions.
|
||||
while op.isDeleted() {
|
||||
guard let nextOp = op.getNextUse().operand else {
|
||||
return nil
|
||||
}
|
||||
op = nextOp
|
||||
}
|
||||
currentOpPtr = op.getNextUse();
|
||||
return Operand(bridged: op)
|
||||
}
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user