File tree Expand file tree Collapse file tree 2 files changed +35
-2
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +35
-2
lines changed Original file line number Diff line number Diff line change @@ -795,14 +795,15 @@ SILInstruction *StackAllocationPromoter::promoteAllocationInBlock(
795
795
continue ;
796
796
}
797
797
if (!runningVals.hasValue ()) {
798
- assert (!deinitializationPoints[blockPromotingWithin]);
799
- deinitializationPoints[blockPromotingWithin] = inst;
800
798
continue ;
801
799
}
802
800
if (sbi->getSrc () != runningVals->value .stored ) {
803
801
continue ;
804
802
}
803
+ // Mark storage as invalid and mark end_borrow as a deinit point.
805
804
runningVals->isStorageValid = false ;
805
+ assert (!deinitializationPoints[blockPromotingWithin]);
806
+ deinitializationPoints[blockPromotingWithin] = inst;
806
807
if (!canEndLexicalLifetime (runningVals->value )) {
807
808
continue ;
808
809
}
Original file line number Diff line number Diff line change @@ -452,3 +452,35 @@ bb0:
452
452
%r = tuple ()
453
453
return %r : $()
454
454
}
455
+
456
+ // CHECK-LABEL: sil [ossa] @test_deinit_point :
457
+ // CHECK: alloc_stack
458
+ // CHECK-NOT: alloc_stack [lexical]
459
+ // CHECK-LABEL: } // end sil function 'test_deinit_point'
460
+ sil [ossa] @test_deinit_point : $@convention(thin) (@guaranteed Klass) -> () {
461
+ bb0(%0 : @guaranteed $Klass):
462
+ %stk = alloc_stack [lexical] $Klass
463
+ cond_br undef, bb1, bb2
464
+
465
+ bb1:
466
+ %tmp = alloc_stack $Klass
467
+ %sb = store_borrow %0 to %tmp : $*Klass
468
+ %f = function_ref @use_inguaranteed : $@convention(thin) (@in_guaranteed Klass) -> ()
469
+ %c = apply %f(%sb) : $@convention(thin) (@in_guaranteed Klass) -> ()
470
+ end_borrow %sb : $*Klass
471
+ dealloc_stack %tmp : $*Klass
472
+ %copy = copy_value %0 : $Klass
473
+ store %copy to [init] %stk : $*Klass
474
+ %l = load [take] %stk : $*Klass
475
+ destroy_value %l : $Klass
476
+ br bb3
477
+
478
+ bb2:
479
+ br bb3
480
+
481
+ bb3:
482
+ dealloc_stack %stk : $*Klass
483
+ %r = tuple ()
484
+ return %r : $()
485
+ }
486
+
You can’t perform that action at this time.
0 commit comments