-
Notifications
You must be signed in to change notification settings - Fork 10.4k
/
Copy patharray_metadata_optimization.swift
23 lines (20 loc) · 1.21 KB
/
array_metadata_optimization.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// RUN: %target-swift-frontend -target x86_64-apple-macosx99.99 -parse-as-library -O -module-name=test %s -Xllvm -sil-print-types -emit-sil | %FileCheck %s
// RUN: %target-swift-frontend -target x86_64-apple-macosx12.3 -parse-as-library -O -module-name=test %s -Xllvm -sil-print-types -emit-sil | %FileCheck %s --check-prefix=NOOPTCLASS
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
// REQUIRES: OS=macosx
// CHECK: sil @$s4test12makeArrayInt1xSaySiGSi_tF
// CHECK: alloc_ref [tail_elems $Int * {{.*}} : $Builtin.Word] $_ContiguousArrayStorage<Int>
// NOOPTCLASS: sil @$s4test12makeArrayInt1xSaySiGSi_tF
// NOOPTCLASS: alloc_ref [tail_elems $Int * {{.*}} : $Builtin.Word] $_ContiguousArrayStorage<Int>
public func makeArrayInt(x: Int) -> [Int] {
return [0, 1, x]
}
// CHECK: sil {{.*}}@$s4test14makeArrayClass1xSayAA1CCGAE_tF
// CHECK: alloc_ref [tail_elems $C * {{.*}} : $Builtin.Word] $_ContiguousArrayStorage<AnyObject>
// NOOPTCLASS: sil {{.*}}@$s4test14makeArrayClass1xSayAA1CCGAE_tF
// NOOPTCLASS: function_ref @$ss29getContiguousArrayStorageType3fors01
// NOOPTCLASS: alloc_ref_dynamic [tail_elems $C * {{.*}} : $Builtin.Word]
public class C {}
public func makeArrayClass(x: C) -> [C] {
return [x, x, x]
}