Skip to content

Commit 3d532cb

Browse files
authored
Merge pull request #31134 from zoecarver/lva/ignore-in-dse
[LVA] Update ignore instructions RLE and DSE.
2 parents c510ae2 + 34ad7d0 commit 3d532cb

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

lib/SILOptimizer/Transforms/DeadStoreElimination.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ static bool isDeadStoreInertInstruction(SILInstruction *Inst) {
161161
case SILInstructionKind::DeallocRefInst:
162162
case SILInstructionKind::CondFailInst:
163163
case SILInstructionKind::FixLifetimeInst:
164+
case SILInstructionKind::EndAccessInst:
165+
case SILInstructionKind::SetDeallocatingInst:
164166
return true;
165167
default:
166168
return false;

lib/SILOptimizer/Transforms/RedundantLoadElimination.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ static bool isRLEInertInstruction(SILInstruction *Inst) {
160160
case SILInstructionKind::IsEscapingClosureInst:
161161
case SILInstructionKind::IsUniqueInst:
162162
case SILInstructionKind::FixLifetimeInst:
163+
case SILInstructionKind::EndAccessInst:
164+
case SILInstructionKind::SetDeallocatingInst:
165+
case SILInstructionKind::DeallocRefInst:
163166
return true;
164167
default:
165168
return false;

test/SILOptimizer/dead_store_elim.sil

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,3 +1501,21 @@ bb0(%0 : $*foo):
15011501
%20 = tuple()
15021502
return %20 : $()
15031503
}
1504+
1505+
// Check that begin_access, end_access, strong_release, set_deallocating, and dealloc_ref don't prevent optimization.
1506+
// CHECK-LABEL: ignore_read_write
1507+
// CHECK: bb0
1508+
// CHECK-NOT: store
1509+
// CHECK-LABEL: end sil function 'ignore_read_write'
1510+
sil @ignore_read_write : $@convention(thin) () -> Int {
1511+
bb0:
1512+
%1 = alloc_ref [stack] $foo
1513+
%2 = integer_literal $Builtin.Int64, 0
1514+
%3 = struct $Int (%2 : $Builtin.Int64)
1515+
%4 = ref_element_addr %1 : $foo, #foo.a
1516+
store %3 to %4 : $*Int
1517+
set_deallocating %1 : $foo
1518+
dealloc_ref %1 : $foo
1519+
dealloc_ref [stack] %1 : $foo
1520+
return %3 : $Int
1521+
}

test/SILOptimizer/redundant_load_elim.sil

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1225,3 +1225,22 @@ bb0(%0 : $*Int):
12251225
%3 = tuple()
12261226
return %3 : $()
12271227
}
1228+
1229+
// Check that begin_access, end_access, strong_release, set_deallocating, and dealloc_ref don't prevent optimization.
1230+
// CHECK-LABEL: ignore_read_write
1231+
// CHECK: bb0
1232+
// CHECK-NOT: load
1233+
// CHECK-LABEL: end sil function 'ignore_read_write'
1234+
sil @ignore_read_write : $@convention(thin) () -> Int32 {
1235+
bb0:
1236+
%1 = alloc_ref [stack] $AX
1237+
%2 = integer_literal $Builtin.Int32, 0
1238+
%3 = struct $Int32 (%2 : $Builtin.Int32)
1239+
%4 = ref_element_addr %1 : $AX, #AX.current
1240+
store %3 to %4 : $*Int32
1241+
%5 = load %4 : $*Int32
1242+
set_deallocating %1 : $AX
1243+
dealloc_ref %1 : $AX
1244+
dealloc_ref [stack] %1 : $AX
1245+
return %5 : $Int32
1246+
}

0 commit comments

Comments
 (0)