File tree Expand file tree Collapse file tree 2 files changed +18
-0
lines changed
lib/SILOptimizer/Analysis Expand file tree Collapse file tree 2 files changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -777,6 +777,11 @@ collectMatchingReleases(SILBasicBlock *BB) {
777777 for (auto II = std::next (BB->rbegin ()), IE = BB->rend (); II != IE; ++II) {
778778 // If we do not have a release_value or strong_release. We can continue
779779 if (!isa<ReleaseValueInst>(*II) && !isa<StrongReleaseInst>(*II)) {
780+
781+ // We cannot match a final release if it is followed by a dealloc_ref.
782+ if (isa<DeallocRefInst>(*II))
783+ break ;
784+
780785 // We do not know what this instruction is, do a simple check to make sure
781786 // that it does not decrement the reference count of any of its operand.
782787 //
Original file line number Diff line number Diff line change @@ -94,6 +94,19 @@ bb0(%0 : $foo, %1 : $*foo):
9494 return %3 : $()
9595}
9696
97+ // CHECK-LABEL: START: sil @dealloc_ref_after_last_release
98+ // CHECK: [[IN1:%.*]] = argument of bb0 : $foo
99+ // CHECK-NOT: strong_release [[IN1]] : $foo
100+ // CHECK: END: sil @dealloc_ref_after_last_release
101+ sil @dealloc_ref_after_last_release : $@convention(thin) (@owned foo) -> () {
102+ bb0(%0 : $foo):
103+ strong_retain %0 : $foo
104+ strong_release %0 : $foo
105+ dealloc_ref %0 : $foo
106+ %3 = tuple ()
107+ return %3 : $()
108+ }
109+
97110// CHECK-LABEL: START: sil @single_release_bar
98111// CHECK: [[IN1:%.*]] = argument of bb0 : $bar
99112// CHECK: strong_release [[IN1]] : $bar
You can’t perform that action at this time.
0 commit comments