Skip to content

Commit 60efd32

Browse files
committed
benchmarks: Remove the StackPromo benchmark and make it a lit test
This benchmark just wants to test if stack promotion of an array literal works. This is so simple that it's better tested with a lit test.
1 parent 1cbed39 commit 60efd32

File tree

4 files changed

+28
-71
lines changed

4 files changed

+28
-71
lines changed

benchmark/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ set(SWIFT_BENCH_MODULES
181181
single-source/SortLargeExistentials
182182
single-source/SortLettersInPlace
183183
single-source/SortStrings
184-
single-source/StackPromo
185184
single-source/StaticArray
186185
single-source/StrComplexWalk
187186
single-source/StrToInt

benchmark/single-source/StackPromo.swift

Lines changed: 0 additions & 65 deletions
This file was deleted.

benchmark/utils/main.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ import SortIntPyramids
186186
import SortLargeExistentials
187187
import SortLettersInPlace
188188
import SortStrings
189-
import StackPromo
190189
import StaticArray
191190
import StrComplexWalk
192191
import StrToInt
@@ -388,7 +387,6 @@ register(SortIntPyramids.benchmarks)
388387
register(SortLargeExistentials.benchmarks)
389388
register(SortLettersInPlace.benchmarks)
390389
register(SortStrings.benchmarks)
391-
register(StackPromo.benchmarks)
392390
register(StaticArray.benchmarks)
393391
register(StrComplexWalk.benchmarks)
394392
register(StrToInt.benchmarks)

test/SILOptimizer/stack_promotion_array_literal.swift

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
// This is an end-to-end test to check if the array literal in the loop is
77
// stack promoted.
88

9-
// CHECK-LABEL: sil @{{.*}}testit
10-
// CHECK: alloc_ref{{.*}} [stack] [tail_elems
11-
9+
// CHECK-LABEL: sil @$s4test6testityySi_SitF :
10+
// CHECK: alloc_ref{{.*}} [stack] [tail_elems
11+
// CHECK: } // end sil function '$s4test6testityySi_SitF'
1212
public func testit(_ N: Int, _ x: Int) {
1313
for _ in 0..<N {
1414
for _ in 0..<10 {
@@ -19,3 +19,28 @@ public func testit(_ N: Int, _ x: Int) {
1919
}
2020
}
2121
}
22+
23+
public protocol Proto {
24+
func at() -> Int
25+
}
26+
27+
// CHECK-LABEL: sil @$s4test5test2ySiAA5Proto_pF :
28+
// CHECK: alloc_ref{{.*}} [stack] [tail_elems $any Proto
29+
// CHECK: br bb1
30+
// CHECK: bb1({{.*}}):
31+
// CHECK: [[M:%.*]] = witness_method
32+
// CHECK: apply [[M]]
33+
// CHECK: cond_br
34+
// CHECK: bb2:
35+
// CHECK: } // end sil function '$s4test5test2ySiAA5Proto_pF'
36+
public func test2(_ p: Proto) -> Int {
37+
var a = [p, p, p]
38+
var b = 0
39+
a.withUnsafeMutableBufferPointer {
40+
let array = $0
41+
for i in 0..<array.count {
42+
b += array[i].at()
43+
}
44+
}
45+
return b
46+
}

0 commit comments

Comments
 (0)