File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
SwiftCompilerSources/Sources/Optimizer/FunctionPasses Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,15 @@ private extension InstructionRange {
188
188
}
189
189
defer { visitor. deinitialize ( ) }
190
190
191
+ // This is important to visit begin_borrows which don't have an end_borrow in dead-end blocks.
192
+ // TODO: we can remove this once we have complete lifetimes.
193
+ visitor. innerScopeHandler = {
194
+ if let inst = $0. definingInstruction {
195
+ liverange. insert ( inst)
196
+ }
197
+ return . continueWalk
198
+ }
199
+
191
200
_ = visitor. visitUses ( )
192
201
self = liverange
193
202
}
Original file line number Diff line number Diff line change @@ -370,3 +370,28 @@ bb0(%0 : @owned $Klass):
370
370
%r = tuple ()
371
371
return %r
372
372
}
373
+
374
+ // CHECK-LABEL: sil [ossa] @borrow_in_deadend_block :
375
+ // CHECK: bb1:
376
+ // CHECK-NEXT: destroy_value %1
377
+ // CHECK-NEXT: destroy_value %2
378
+ // CHECK: } // end sil function 'borrow_in_deadend_block'
379
+ sil [ossa] @borrow_in_deadend_block : $@convention(thin) (@in Klass) -> () {
380
+ bb0(%0 : $*Klass):
381
+ %1 = load [take] %0
382
+ %2 = copy_value %1
383
+ %3 = begin_borrow %1
384
+ end_borrow %3
385
+ cond_br undef, bb1, bb2
386
+
387
+ bb1:
388
+ destroy_value %1
389
+ destroy_value %2
390
+ %8 = tuple ()
391
+ return %8
392
+
393
+ bb2:
394
+ %10 = begin_borrow %1
395
+ unreachable
396
+ }
397
+
You can’t perform that action at this time.
0 commit comments