Skip to content

ARC: fix epilog-release-matcher. It has to handle dealloc_ref instructions #4599

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/SILOptimizer/Analysis/ARCAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -777,6 +777,11 @@ collectMatchingReleases(SILBasicBlock *BB) {
for (auto II = std::next(BB->rbegin()), IE = BB->rend(); II != IE; ++II) {
// If we do not have a release_value or strong_release. We can continue
if (!isa<ReleaseValueInst>(*II) && !isa<StrongReleaseInst>(*II)) {

// We cannot match a final release if it is followed by a dealloc_ref.
if (isa<DeallocRefInst>(*II))
break;

// We do not know what this instruction is, do a simple check to make sure
// that it does not decrement the reference count of any of its operand.
//
Expand Down
13 changes: 13 additions & 0 deletions test/SILOptimizer/epilogue_release_dumper.sil
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,19 @@ bb0(%0 : $foo, %1 : $*foo):
return %3 : $()
}

// CHECK-LABEL: START: sil @dealloc_ref_after_last_release
// CHECK: [[IN1:%.*]] = argument of bb0 : $foo
// CHECK-NOT: strong_release [[IN1]] : $foo
// CHECK: END: sil @dealloc_ref_after_last_release
sil @dealloc_ref_after_last_release : $@convention(thin) (@owned foo) -> () {
bb0(%0 : $foo):
strong_retain %0 : $foo
strong_release %0 : $foo
dealloc_ref %0 : $foo
%3 = tuple ()
return %3 : $()
}

// CHECK-LABEL: START: sil @single_release_bar
// CHECK: [[IN1:%.*]] = argument of bb0 : $bar
// CHECK: strong_release [[IN1]] : $bar
Expand Down