File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
lib/SILOptimizer/Transforms Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,10 @@ static bool seemsUseful(SILInstruction *I) {
5555 isa<EndBorrowInst>(I))
5656 return false ;
5757
58+ if (isa<UnconditionalCheckedCastInst>(I)) {
59+ return false ;
60+ }
61+
5862 // A load [copy] is okay to be DCE'ed if there are no useful dependencies
5963 if (auto *load = dyn_cast<LoadInst>(I)) {
6064 if (load->getOwnershipQualifier () == LoadOwnershipQualifier::Copy)
Original file line number Diff line number Diff line change @@ -270,3 +270,18 @@ bb0(%0 : $*Container):
270270 %999 = tuple ()
271271 return %999 : $()
272272}
273+
274+ class B {}
275+
276+ // CHECK-LABEL: sil @dead_unconditional_checked_cast
277+ // CHECK-NOT: unconditional_checked_cast
278+ // CHECK-LABEL: end sil function 'dead_unconditional_checked_cast'
279+ sil @dead_unconditional_checked_cast : $@convention(thin) (B, B) -> () {
280+ bb0(%0 : $B, %1: $B):
281+ strong_retain %0: $B
282+ apply undef() : $@convention(thin) () -> ()
283+ %3 = unconditional_checked_cast %0 : $B to Builtin.NativeObject
284+ strong_release %0: $B
285+ %5 = tuple()
286+ return %5 : $()
287+ }
You can’t perform that action at this time.
0 commit comments