File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
lib/SILOptimizer/SILCombiner Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -472,6 +472,9 @@ visitUncheckedTrivialBitCastInst(UncheckedTrivialBitCastInst *UTBCI) {
472472SILInstruction *
473473SILCombiner::
474474visitUncheckedBitwiseCastInst (UncheckedBitwiseCastInst *UBCI) {
475+ if (UBCI->getFunction ()->hasOwnership ())
476+ return nullptr ;
477+
475478 // (unchecked_bitwise_cast Y->Z (unchecked_bitwise_cast X->Y x))
476479 // OR (unchecked_trivial_cast Y->Z (unchecked_bitwise_cast X->Y x))
477480 // ->
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ sil_stage canonical
88import Builtin
99import Swift
1010
11+ class Klass {}
1112class RawBuffer {}
1213class HeapBufferStorage<T, U> : RawBuffer {}
1314
@@ -4116,3 +4117,16 @@ bb0:
41164117 %1 = load %0 : $*Int64
41174118 return %1 : $Int64
41184119}
4120+
4121+ // Check for disabled optimization of unchecked_bitwise_cast to unchecked_ref_cast in ossa
4122+ // This test can be optimized when ossa is supported in the SILCombine for unchecked_bitwise_cast
4123+ // CHECK-LABEL: sil [ossa] @refcast :
4124+ // CHECK: unchecked_bitwise_cast
4125+ // CHECK-LABEL: } // end sil function 'refcast'
4126+ sil [ossa] @refcast : $@convention(thin) (@owned Klass) -> @owned Optional<Klass> {
4127+ bb0(%0 : @owned $Klass):
4128+ %1 = unchecked_bitwise_cast %0 : $Klass to $Optional<Klass>
4129+ %2 = copy_value %1 : $Optional<Klass>
4130+ destroy_value %0 : $Klass
4131+ return %2 : $Optional<Klass>
4132+ }
You can’t perform that action at this time.
0 commit comments