1
- // RUN: %target-swift-frontend -O -sil-verify-all -emit-sil %s | %FileCheck %s
1
+ // RUN: %target-swift-frontend -O -sil-verify-all -emit-sil -Xllvm '-sil-inline-never-functions=$sSa6append' %s | %FileCheck %s
2
2
// REQUIRES: swift_stdlib_no_asserts,optimized_stdlib
3
3
4
- // This is an end-to-end test of the array(contentsOf) -> array(Element) optimization
4
+ // This is an end-to-end test of the Array.append(contentsOf:) ->
5
+ // Array.append(Element) optimization.
6
+ //
7
+ // To check that the optimization produces the expected
8
+ // Array.append(Element) calls, the CHECK lines match those call
9
+ // sites. The optimizer may subsequently inline Array.append(Element),
10
+ // which is good, but to keep the test simple and specific to the
11
+ // optimization, the RUN line prevents inlining Array.append(Element).
12
+ // Likewise, negative tests check for the existence of
13
+ // Array.append(contentsOf:), so don't inline those either.
5
14
6
15
// CHECK-LABEL: sil @{{.*}}testInt
7
16
// CHECK-NOT: apply
@@ -22,14 +31,13 @@ public func testInt(_ a: inout [Int]) {
22
31
// CHECK-DAG: apply [[F]]
23
32
// CHECK-DAG: apply [[F]]
24
33
// CHECK: } // end sil function '{{.*}}testThreeInts{{.*}}'
25
-
26
34
public func testThreeInts( _ a: inout [ Int ] ) {
27
35
a += [ 1 , 2 , 3 ]
28
36
}
29
37
30
38
// CHECK-LABEL: sil @{{.*}}testTooManyInts
31
39
// CHECK-NOT: apply
32
- // CHECK: [[F:%[0-9]+]] = function_ref @$sSa6append10contentsOfyqd__n_t7ElementQyd__RszSTRd__lFSi_SaySiGTg5Tf4gn_n
40
+ // CHECK: [[F:%[0-9]+]] = function_ref @$sSa6append10contentsOfyqd__n_t7ElementQyd__RszSTRd__lFSi_SaySiGTg5
33
41
// CHECK-NOT: apply
34
42
// CHECK: apply [[F]]
35
43
// CHECK-NOT: apply
@@ -57,7 +65,7 @@ public func dontPropagateContiguousArray(_ a: inout ContiguousArray<UInt8>) {
57
65
58
66
// Check if the specialized Array.append<A>(contentsOf:) is reasonably optimized for Array<Int>.
59
67
60
- // CHECK-LABEL: sil shared {{.*}}@$sSa6append10contentsOfyqd__n_t7ElementQyd__RszSTRd__lFSi_SaySiGTg5
68
+ // CHECK-LABEL: sil shared {{.*}}@$sSa6append10contentsOfyqd__n_t7ElementQyd__RszSTRd__lFSi_SaySiGTg5Tf4gn_n
61
69
62
70
// There should only be a single call to _createNewBuffer or reserveCapacityForAppend/reserveCapacityImpl.
63
71
0 commit comments