@@ -91,7 +91,9 @@ private func optimize(value: Value, _ context: FunctionPassContext) {
9191 var hoistableDestroys = selectHoistableDestroys ( of: value, context)
9292 defer { hoistableDestroys. deinitialize ( ) }
9393
94- var minimalLiverange = InstructionRange ( withLiverangeOf: value, ignoring: hoistableDestroys, context)
94+ guard var minimalLiverange = InstructionRange ( withLiverangeOf: value, ignoring: hoistableDestroys, context) else {
95+ return
96+ }
9597 defer { minimalLiverange. deinitialize ( ) }
9698
9799 hoistDestroys ( of: value, toEndOf: minimalLiverange, restrictingTo: & hoistableDestroys, context)
@@ -177,10 +179,10 @@ private func removeDestroys(
177179
178180private extension InstructionRange {
179181
180- init ( withLiverangeOf initialDef: Value , ignoring ignoreDestroys: InstructionSet , _ context: FunctionPassContext )
182+ init ? ( withLiverangeOf initialDef: Value , ignoring ignoreDestroys: InstructionSet , _ context: FunctionPassContext )
181183 {
182184 var liverange = InstructionRange ( for: initialDef, context)
183- var visitor = InteriorUseWalker ( definingValue: initialDef, ignoreEscape: true , visitInnerUses: true , context) {
185+ var visitor = InteriorUseWalker ( definingValue: initialDef, ignoreEscape: false , visitInnerUses: true , context) {
184186 if !ignoreDestroys. contains ( $0. instruction) {
185187 liverange. insert ( $0. instruction)
186188 }
@@ -197,7 +199,10 @@ private extension InstructionRange {
197199 return . continueWalk
198200 }
199201
200- _ = visitor. visitUses ( )
202+ guard visitor. visitUses ( ) == . continueWalk else {
203+ liverange. deinitialize ( )
204+ return nil
205+ }
201206 self = liverange
202207 }
203208
0 commit comments