File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
lib/SILOptimizer/SILCombiner Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -900,8 +900,9 @@ visitUncheckedBitwiseCastInst(UncheckedBitwiseCastInst *UBCI) {
900
900
901
901
OwnershipRAUWHelper helper (ownershipFixupContext, UBCI, Oper);
902
902
if (helper) {
903
+ SILBuilderWithScope localBuilder (std::next (UBCI->getIterator ()), Builder);
903
904
auto replacement = helper.prepareReplacement ();
904
- auto *transformedOper = Builder .createUncheckedBitwiseCast (
905
+ auto *transformedOper = localBuilder .createUncheckedBitwiseCast (
905
906
UBCI->getLoc (), replacement, UBCI->getType ());
906
907
helper.perform (transformedOper);
907
908
return nullptr ;
Original file line number Diff line number Diff line change 5
5
6
6
sil_stage canonical
7
7
8
+ import Swift
8
9
import Builtin
9
10
10
11
class Klass {}
81
82
destroy_value %obj : $KlassWithTailAllocatedElems
82
83
return %val : $Builtin.Word
83
84
}
85
+
86
+ sil @get_native_object : $@convention(thin) () -> @owned Builtin.NativeObject
87
+
88
+ // CHECK-LABEL: sil [ossa] @bitwise_combines_guaranteed :
89
+ // CHECK: unchecked_ref_cast
90
+ // CHECK-LABEL: } // end sil function 'bitwise_combines_guaranteed'
91
+ sil [ossa] @bitwise_combines_guaranteed : $@convention(thin) () -> @owned Optional<Builtin.NativeObject> {
92
+ bb0:
93
+ %f = function_ref @get_native_object : $@convention(thin) () -> @owned Builtin.NativeObject
94
+ %0 = apply %f() : $@convention(thin) () -> @owned Builtin.NativeObject
95
+ %b = begin_borrow [lexical] %0 : $Builtin.NativeObject
96
+ br bb1
97
+
98
+ bb1:
99
+ %2 = unchecked_trivial_bit_cast %b : $Builtin.NativeObject to $Builtin.Word
100
+ %3 = unchecked_bitwise_cast %2 : $Builtin.Word to $Optional<Builtin.NativeObject>
101
+ %c = copy_value %3 : $Optional<Builtin.NativeObject>
102
+ end_borrow %b : $Builtin.NativeObject
103
+ destroy_value %0 : $Builtin.NativeObject
104
+ return %c : $Optional<Builtin.NativeObject>
105
+ }
106
+
You can’t perform that action at this time.
0 commit comments