Skip to content

Commit 0cbf356

Browse files
committed
tests: enable SILOptimizer/copy-to-borrow-optimization.sil for all OSes
By defining its own array structs, which are independent from objc interop. Also, the requires-line was wrong anyway. The test didn't run on macos either.
1 parent 2dbe751 commit 0cbf356

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

test/SILOptimizer/copy-to-borrow-optimization.sil

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// RUN: %target-sil-opt -copy-to-borrow-optimization %s | %FileCheck %s
2-
// REQUIRES: macosx
32

43
sil_stage canonical
54

@@ -82,6 +81,22 @@ struct NonTrivialStruct {
8281
var val: Klass
8382
}
8483

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+
85100
sil @getKlass : $@convention(thin) () -> @owned Klass
86101
sil @guaranteed_klass_user : $@convention(thin) (@guaranteed Klass) -> ()
87102
sil @use_inguaranteed : $@convention(thin) (@in_guaranteed Klass) -> ()
@@ -2242,19 +2257,19 @@ bb1(%1 : @guaranteed $C):
22422257
// CHECK-LABEL: sil [ossa] @borrowed_from_forward2 : {{.*}} {
22432258
// CHECK-NOT: copy_value
22442259
// 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
22512266
br bb1(%4)
22522267

2253-
bb1(%6 : @guaranteed $__ContiguousArrayStorageBase):
2268+
bb1(%6 : @guaranteed $MyArrayStorageBase):
22542269
%7 = borrowed %6 from (%0)
22552270
%8 = copy_value %7
22562271
%9 = begin_borrow %8
2257-
%10 = ref_element_addr [immutable] %9, #__ContiguousArrayStorageBase.countAndCapacity
2272+
%10 = ref_element_addr [immutable] %9, #MyArrayStorageBase.countAndCapacity
22582273
end_borrow %9
22592274
destroy_value %8
22602275
%13 = tuple ()

0 commit comments

Comments
 (0)