@@ -14,6 +14,10 @@ struct X {
14
14
init()
15
15
}
16
16
17
+ class Klass {
18
+
19
+ }
20
+
17
21
var globalX: X
18
22
19
23
var globalOtherX: X
@@ -1789,3 +1793,27 @@ bb0(%0 : $*T):
1789
1793
%108 = tuple ()
1790
1794
return %108 : $()
1791
1795
}
1796
+
1797
+ // Test that SILInstruction::mayRelease recognizes
1798
+ // unchecked_ownership_conversion without asserting.
1799
+ // CHECK-LABEL: sil hidden [ossa] @$testUncheckedOwnershipConversion :
1800
+ // CHECK: begin_access
1801
+ // CHECK: unchecked_ownership_conversion
1802
+ // CHECK-LABEL: } // end sil function '$testUncheckedOwnershipConversion'
1803
+ sil hidden [ossa] @$testUncheckedOwnershipConversion : $@convention(method) (@guaranteed Klass, @in Int64) -> @owned Builtin.NativeObject {
1804
+ bb0(%0 : @guaranteed $Klass, %1 : $*Int64):
1805
+ %2 = begin_access [modify] [dynamic] %1 : $*Int64
1806
+ %3 = struct_element_addr %2 : $*Int64, #Int64._value
1807
+ %4 = load [trivial] %3 : $*Builtin.Int64
1808
+ %5 = integer_literal $Builtin.Int1, -1
1809
+ %6 = builtin "ssub_with_overflow_Int64"(%4 : $Builtin.Int64, %4 : $Builtin.Int64, %5 : $Builtin.Int1) : $(Builtin.Int64, Builtin.Int1)
1810
+ (%7, %8) = destructure_tuple %6 : $(Builtin.Int64, Builtin.Int1)
1811
+ cond_fail %8 : $Builtin.Int1, "arithmetic overflow"
1812
+ %10 = struct $Int64 (%7 : $Builtin.Int64)
1813
+ store %10 to [trivial] %2 : $*Int64
1814
+ end_access %2 : $*Int64
1815
+ %13 = unchecked_ref_cast %0 : $Klass to $Builtin.NativeObject
1816
+ %14 = unchecked_ownership_conversion %13 : $Builtin.NativeObject, @guaranteed to @owned
1817
+ return %14 : $Builtin.NativeObject
1818
+ }
1819
+
0 commit comments