|
| 1 | +// RUN: %target-sil-opt -enable-sil-verify-all %s -onone-simplification -simplify-instruction=keypath | %FileCheck %s |
| 2 | + |
| 3 | +sil_stage canonical |
| 4 | + |
| 5 | +import Builtin |
| 6 | +import Swift |
| 7 | + |
| 8 | +struct S { |
| 9 | + @_hasStorage var a: Int |
| 10 | + @_hasStorage var b: Int |
| 11 | +} |
| 12 | + |
| 13 | +// CHECK-LABEL: sil [ossa] @remove_dead_keypath_ossa : |
| 14 | +// CHECK-NOT: keypath |
| 15 | +// CHECK-NOT: destroy_value |
| 16 | +// CHECK: %0 = tuple |
| 17 | +// CHECK-NEXT: return |
| 18 | +// CHECK: } // end sil function 'remove_dead_keypath_ossa' |
| 19 | +sil [ossa] @remove_dead_keypath_ossa : $@convention(thin) () -> () { |
| 20 | +bb0: |
| 21 | + %0 = keypath $WritableKeyPath<S, Int>, (root $S; stored_property #S.b : $Int) |
| 22 | + %1 = upcast %0 : $WritableKeyPath<S, Int> to $KeyPath<S, Int> |
| 23 | + %2 = begin_borrow %1 : $KeyPath<S, Int> |
| 24 | + end_borrow %2 : $KeyPath<S, Int> |
| 25 | + %4 = copy_value %1 : $KeyPath<S, Int> |
| 26 | + %5 = move_value %4 : $KeyPath<S, Int> |
| 27 | + destroy_value %1 : $KeyPath<S, Int> |
| 28 | + destroy_value %5 : $KeyPath<S, Int> |
| 29 | + %r = tuple() |
| 30 | + return %r : $() |
| 31 | +} |
| 32 | + |
| 33 | +// CHECK-LABEL: sil @remove_dead_keypath : |
| 34 | +// CHECK-NOT: keypath |
| 35 | +// CHECK-NOT: strong_release |
| 36 | +// CHECK: %0 = tuple |
| 37 | +// CHECK-NEXT: return |
| 38 | +// CHECK: } // end sil function 'remove_dead_keypath' |
| 39 | +sil @remove_dead_keypath : $@convention(thin) () -> () { |
| 40 | +bb0: |
| 41 | + %0 = keypath $WritableKeyPath<S, Int>, (root $S; stored_property #S.b : $Int) |
| 42 | + %1 = upcast %0 : $WritableKeyPath<S, Int> to $KeyPath<S, Int> |
| 43 | + strong_release %1 : $KeyPath<S, Int> |
| 44 | + %r = tuple() |
| 45 | + return %r : $() |
| 46 | +} |
| 47 | + |
0 commit comments