File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,12 @@ namespace {
40
40
// FIXME: Reconcile the similarities between this and
41
41
// isInstructionTriviallyDead.
42
42
static bool seemsUseful (SILInstruction *I) {
43
+ if (auto access = dyn_cast<BeginAccessInst>(I))
44
+ return access->getSingleUse () == nullptr && !access->use_empty ();
45
+
46
+ if (isa<EndAccessInst>(I))
47
+ return I->getOperand (0 )->getSingleUse () == nullptr ;
48
+
43
49
if (I->mayHaveSideEffects ())
44
50
return true ;
45
51
Original file line number Diff line number Diff line change @@ -259,3 +259,21 @@ bb2:
259
259
bb3:
260
260
br bb1
261
261
}
262
+
263
+ // Check that DCE eliminates dead access instructions.
264
+ // CHECK-LABEL: sil @dead_access
265
+ // CHECK: bb0
266
+ // CHECK-NEXT: tuple
267
+ // CHECK-NEXT: return
268
+ // CHECK-LABEL: end sil function 'dead_access'
269
+ sil @dead_access : $@convention(thin) (@in Container) -> () {
270
+ bb0(%0 : $*Container):
271
+ %1 = begin_access [modify] [dynamic] %0 : $*Container
272
+ end_access %1 : $*Container
273
+
274
+ %3 = begin_access [read] [static] %0 : $*Container
275
+ end_access %3 : $*Container
276
+
277
+ %999 = tuple ()
278
+ return %999 : $()
279
+ }
You can’t perform that action at this time.
0 commit comments