[sil-combine] Minor improvement to the peephole for removal of alloc_ref instructions that are only allocated and then deallocated

This commit is contained in:
Roman Levenstein
2017-08-01 13:52:33 -07:00
parent 71743d6a12
commit f802fe4829
2 changed files with 16 additions and 1 deletions

View File

@@ -447,7 +447,8 @@ SILInstruction *SILCombiner::visitAllocRefInst(AllocRefInst *AR) {
auto *Op = *UI;
++UI;
auto *User = Op->getUser();
if (!isa<DeallocRefInst>(User) && !isa<SetDeallocatingInst>(User)) {
if (!isa<DeallocRefInst>(User) && !isa<SetDeallocatingInst>(User) &&
!isa<FixLifetimeInst>(User)) {
HasNonRemovableUses = true;
break;
}

View File

@@ -2413,6 +2413,20 @@ bb0(%0 : $*B):
return %2 : $()
}
// CHECK-LABEL: sil @delete_dead_alloc_ref
// CHECK: bb0
// CHECK-NEXT: tuple
// CHECK-NEXT: return
sil @delete_dead_alloc_ref : $() -> () {
bb0:
%1 = alloc_ref $B
set_deallocating %1 : $B
fix_lifetime %1 : $B
dealloc_ref %1 : $B
%2 = tuple()
return %2 : $()
}
// CHECK-LABEL: sil @delete_dead_alloc_stack2
// CHECK: bb0
// CHECK-NEXT: destroy_addr %0