|
1 | 1 | // RUN: %target-sil-opt -copy-to-borrow-optimization %s | %FileCheck %s |
2 | | -// REQUIRES: macosx |
3 | 2 |
|
4 | 3 | sil_stage canonical |
5 | 4 |
|
@@ -82,6 +81,22 @@ struct NonTrivialStruct { |
82 | 81 | var val: Klass |
83 | 82 | } |
84 | 83 |
|
| 84 | +class MyArrayStorageBase { |
| 85 | + @_hasStorage let countAndCapacity: Int |
| 86 | +} |
| 87 | + |
| 88 | +struct MyBridgeStorage { |
| 89 | + let rawValue: Builtin.NativeObject |
| 90 | +} |
| 91 | + |
| 92 | +struct MyArrayBuffer { |
| 93 | + let storage: MyBridgeStorage |
| 94 | +} |
| 95 | + |
| 96 | +struct MyArray { |
| 97 | + let buffer: MyArrayBuffer |
| 98 | +} |
| 99 | + |
85 | 100 | sil @getKlass : $@convention(thin) () -> @owned Klass |
86 | 101 | sil @guaranteed_klass_user : $@convention(thin) (@guaranteed Klass) -> () |
87 | 102 | sil @use_inguaranteed : $@convention(thin) (@in_guaranteed Klass) -> () |
@@ -2242,19 +2257,19 @@ bb1(%1 : @guaranteed $C): |
2242 | 2257 | // CHECK-LABEL: sil [ossa] @borrowed_from_forward2 : {{.*}} { |
2243 | 2258 | // CHECK-NOT: copy_value |
2244 | 2259 | // CHECK-LABEL: } // end sil function 'borrowed_from_forward2' |
2245 | | -sil [ossa] @borrowed_from_forward2 : $@convention(thin) (@guaranteed Array<Int>) -> () { |
2246 | | -bb0(%0 : @guaranteed $Array<Int>): |
2247 | | - %1 = struct_extract %0, #Array._buffer |
2248 | | - %2 = struct_extract %1, #_ArrayBuffer._storage |
2249 | | - %3 = struct_extract %2, #_BridgeStorage.rawValue |
2250 | | - %4 = unchecked_ref_cast %3 to $__ContiguousArrayStorageBase |
| 2260 | +sil [ossa] @borrowed_from_forward2 : $@convention(thin) (@guaranteed MyArray) -> () { |
| 2261 | +bb0(%0 : @guaranteed $MyArray): |
| 2262 | + %1 = struct_extract %0, #MyArray.buffer |
| 2263 | + %2 = struct_extract %1, #MyArrayBuffer.storage |
| 2264 | + %3 = struct_extract %2, #MyBridgeStorage.rawValue |
| 2265 | + %4 = unchecked_ref_cast %3 to $MyArrayStorageBase |
2251 | 2266 | br bb1(%4) |
2252 | 2267 |
|
2253 | | -bb1(%6 : @guaranteed $__ContiguousArrayStorageBase): |
| 2268 | +bb1(%6 : @guaranteed $MyArrayStorageBase): |
2254 | 2269 | %7 = borrowed %6 from (%0) |
2255 | 2270 | %8 = copy_value %7 |
2256 | 2271 | %9 = begin_borrow %8 |
2257 | | - %10 = ref_element_addr [immutable] %9, #__ContiguousArrayStorageBase.countAndCapacity |
| 2272 | + %10 = ref_element_addr [immutable] %9, #MyArrayStorageBase.countAndCapacity |
2258 | 2273 | end_borrow %9 |
2259 | 2274 | destroy_value %8 |
2260 | 2275 | %13 = tuple () |
|
0 commit comments