mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user