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) {
472
472
SILInstruction *
473
473
SILCombiner::
474
474
visitUncheckedBitwiseCastInst (UncheckedBitwiseCastInst *UBCI) {
475
+ if (UBCI->getFunction ()->hasOwnership ())
476
+ return nullptr ;
477
+
475
478
// (unchecked_bitwise_cast Y->Z (unchecked_bitwise_cast X->Y x))
476
479
// OR (unchecked_trivial_cast Y->Z (unchecked_bitwise_cast X->Y x))
477
480
// ->
Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ sil_stage canonical
8
8
import Builtin
9
9
import Swift
10
10
11
+ class Klass {}
11
12
class RawBuffer {}
12
13
class HeapBufferStorage<T, U> : RawBuffer {}
13
14
@@ -4116,3 +4117,16 @@ bb0:
4116
4117
%1 = load %0 : $*Int64
4117
4118
return %1 : $Int64
4118
4119
}
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