File tree Expand file tree Collapse file tree 2 files changed +47
-4
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +47
-4
lines changed Original file line number Diff line number Diff line change @@ -45,10 +45,11 @@ namespace {
45
45
// FIXME: Reconcile the similarities between this and
46
46
// isInstructionTriviallyDead.
47
47
static bool seemsUseful (SILInstruction *I) {
48
- // Even though begin_access/destroy_value/copy_value have side-effects, they
49
- // can be DCE'ed if they do not have useful dependencies/reverse dependencies
48
+ // Even though begin_access/destroy_value/copy_value/end_lifetime have
49
+ // side-effects, they can be DCE'ed if they do not have useful
50
+ // dependencies/reverse dependencies
50
51
if (isa<BeginAccessInst>(I) || isa<CopyValueInst>(I) ||
51
- isa<DestroyValueInst>(I))
52
+ isa<DestroyValueInst>(I) || isa<EndLifetimeInst>(I) )
52
53
return false ;
53
54
54
55
// A load [copy] is okay to be DCE'ed if there are no useful dependencies
@@ -268,7 +269,8 @@ void DCE::markLive() {
268
269
break ;
269
270
}
270
271
case SILInstructionKind::DestroyValueInst:
271
- case SILInstructionKind::EndBorrowInst: {
272
+ case SILInstructionKind::EndBorrowInst:
273
+ case SILInstructionKind::EndLifetimeInst: {
272
274
// The instruction is live only if it's operand value is also live
273
275
addReverseDependency (I.getOperand (0 ), &I);
274
276
break ;
Original file line number Diff line number Diff line change @@ -611,3 +611,44 @@ bb3:
611
611
return %9999 : $()
612
612
}
613
613
614
+ // CHECK-LABEL: sil [ossa] @dce_deadendlifetime1 :
615
+ // CHECK-NOT: end_lifetime
616
+ // CHECK-LABEL: } // end sil function 'dce_deadendlifetime1'
617
+ sil [ossa] @dce_deadendlifetime1 : $@convention(thin) () -> () {
618
+ bb0:
619
+ cond_br undef, bb1, bb2
620
+
621
+ bb1:
622
+ br bb3(undef : $Klass)
623
+
624
+ bb2:
625
+ br bb3(undef : $Klass)
626
+
627
+ bb3(%2 : @owned $Klass):
628
+ end_lifetime %2 : $Klass
629
+ %res = tuple ()
630
+ return %res : $()
631
+ }
632
+
633
+ // CHECK-LABEL: sil [ossa] @dce_deadendlifetime2 :
634
+ // CHECK-NOT: end_lifetime
635
+ // CHECK-LABEL: } // end sil function 'dce_deadendlifetime2'
636
+ sil [ossa] @dce_deadendlifetime2 : $@convention(thin) () -> () {
637
+ bb0:
638
+ cond_br undef, bb1, bb2
639
+
640
+ bb1:
641
+ br bb3(undef : $Klass)
642
+
643
+ bb2:
644
+ br bb3(undef : $Klass)
645
+
646
+ bb3(%2 : @owned $Klass):
647
+ br bb4(%2 : $Klass)
648
+
649
+ bb4(%3 : @owned $Klass):
650
+ end_lifetime %3 : $Klass
651
+ %res = tuple ()
652
+ return %res : $()
653
+ }
654
+
You can’t perform that action at this time.
0 commit comments