@@ -1760,3 +1760,32 @@ bb0(%0 : @guaranteed ${ var Int64 }):
17601760 end_access %access : $*Int64
17611761 return %val : $Int64
17621762}
1763+
1764+
1765+ // Test that SILInstruction::mayRelease recognizes
1766+ // unmanaged_release_value without asserting.
1767+ // CHECK-LABEL: sil [transparent] [serialized] [ossa] @testUnmanagedRelease : $@convention(method) <T where T : AnyObject> (@inout T) -> () {
1768+ // CHECK: begin_access
1769+ // CHECK: unmanaged_release_value
1770+ // CHECK-LABEL: } // end sil function 'testUnmanagedRelease'
1771+ sil [transparent] [serialized] [ossa] @testUnmanagedRelease : $@convention(method) <T where T : AnyObject> (@inout T) -> () {
1772+ bb0(%0 : $*T):
1773+ %access = begin_access [modify] [dynamic] %0 : $*T
1774+ %load = load [copy] %access : $*T
1775+ end_access %access : $*T
1776+ %unmanaged1 = ref_to_unmanaged %load : $T to $@sil_unmanaged T
1777+ %copy1 = strong_copy_unmanaged_value %unmanaged1 : $@sil_unmanaged T
1778+ unmanaged_retain_value %copy1 : $T
1779+ %cast1 = unchecked_bitwise_cast %copy1 : $T to $UnsafeRawPointer
1780+ destroy_value %copy1 : $T
1781+ %cast2 = unchecked_bitwise_cast %cast1 : $UnsafeRawPointer to $T
1782+ %copy2 = copy_value %cast2 : $T
1783+ %unmanaged2 = ref_to_unmanaged %copy2 : $T to $@sil_unmanaged T
1784+ destroy_value %copy2 : $T
1785+ %copy3 = strong_copy_unmanaged_value %unmanaged2 : $@sil_unmanaged T
1786+ unmanaged_release_value %copy3 : $T
1787+ destroy_value %copy3 : $T
1788+ destroy_value %load : $T
1789+ %108 = tuple ()
1790+ return %108 : $()
1791+ }
0 commit comments