@@ -91,7 +91,9 @@ private func optimize(value: Value, _ context: FunctionPassContext) {
91
91
var hoistableDestroys = selectHoistableDestroys ( of: value, context)
92
92
defer { hoistableDestroys. deinitialize ( ) }
93
93
94
- var minimalLiverange = InstructionRange ( withLiverangeOf: value, ignoring: hoistableDestroys, context)
94
+ guard var minimalLiverange = InstructionRange ( withLiverangeOf: value, ignoring: hoistableDestroys, context) else {
95
+ return
96
+ }
95
97
defer { minimalLiverange. deinitialize ( ) }
96
98
97
99
hoistDestroys ( of: value, toEndOf: minimalLiverange, restrictingTo: & hoistableDestroys, context)
@@ -177,7 +179,7 @@ private func removeDestroys(
177
179
178
180
private extension InstructionRange {
179
181
180
- init ( withLiverangeOf initialDef: Value , ignoring ignoreDestroys: InstructionSet , _ context: FunctionPassContext )
182
+ init ? ( withLiverangeOf initialDef: Value , ignoring ignoreDestroys: InstructionSet , _ context: FunctionPassContext )
181
183
{
182
184
var liverange = InstructionRange ( for: initialDef, context)
183
185
var visitor = InteriorUseWalker ( definingValue: initialDef, ignoreEscape: true , visitInnerUses: true , context) {
@@ -197,7 +199,9 @@ private extension InstructionRange {
197
199
return . continueWalk
198
200
}
199
201
200
- _ = visitor. visitUses ( )
202
+ guard visitor. visitUses ( ) == . continueWalk else {
203
+ return nil
204
+ }
201
205
self = liverange
202
206
}
203
207
0 commit comments