Skip to content

Commit 3aba550

Browse files
committed
Add more type checker performance tests.
1 parent c076d4b commit 3aba550

16 files changed

+173
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
// Mixed UInt32 and Double
5+
let x: UInt32 = 1
6+
let _ = x > (33 + 55 + 6 + 55 + 6 + 55 + 6 + 55 + 6 + 27.5)
7+
// expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
let _ = [0].reduce([Int]()) {
5+
// expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
6+
return $0.count == 0 && $1 == 0 ? [] : $0 + [$1]
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
let a: [Double] = []
5+
_ = a.map { $0 - 1.0 }
6+
// expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
7+
.map { $0 * $0 }
8+
.reduce(0, +) / Double(a.count)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
struct S { var s: String? }
5+
6+
func rdar23861629(_ a: [S]) {
7+
_ = a.reduce("") {
8+
// expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
9+
($0 == "") ? ($1.s ?? "") : $0 + "," + ($1.s ?? "")
10+
}
11+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
func rdar26564101(a: [Double], m: Double) -> Double {
5+
return Double(Array(0...a.count - 1).reduce(0) { $0 + $1 - m })
6+
// expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
func fun(_ x: Double) -> Double { fatalError() }
5+
6+
func test(l: Double, s: Float) {
7+
_ = fun((l / 2.0) * (l / 2.0) * (l / 2.0) / (1.0 + s * s))
8+
// expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
9+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: not %scale-test --begin 7 --end 9 --step 1 --select incrementScopeCounter %s
2+
// REQUIRES: OS=macosx
3+
// REQUIRES: asserts
4+
5+
enum X : String {
6+
case first
7+
}
8+
9+
enum Y : Int {
10+
case first
11+
}
12+
13+
_ =
14+
[
15+
%for i in range(0, N):
16+
[
17+
X.first : Y.first
18+
],
19+
%end
20+
[
21+
X.first : "literal",
22+
],
23+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
let a = 1
5+
6+
_ = -a + -a - -a + -a - -a
7+
// expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
func rdar31742586() -> Double {
5+
return -(1 + 2) + -(3 + 4) + 5
6+
// expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
struct S {
5+
var A: [[UInt32]]
6+
7+
func rdar32034560(x: UInt32) -> UInt32 {
8+
return ((self.A[0][Int(x >> 24) & 0xFF] &+ self.A[1][Int(x >> 16) & 0xFF]) ^ self.A[2][Int(x >> 8) & 0xFF]) &+ self.A[3][Int(x & 0xFF)] |
9+
((self.A[0][Int(x >> 24) & 0xFF] &+ self.A[1][Int(x >> 16) & 0xFF]) ^ self.A[2][Int(x >> 8) & 0xFF]) &+ self.A[3][Int(x & 0xFF)]
10+
// expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
11+
}
12+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1 -swift-version 4
2+
// REQUIRES: tools-release,no_asserts
3+
4+
func rdar32998180(value: UInt16) -> UInt16 {
5+
var result = (((value >> 1) ^ (value >> 1) ^ (value >> 1) ^ (value >> 1)) & 1) << 1
6+
// expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
7+
return result
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: not %scale-test --begin 1 --end 3 --step 1 --select incrementScopeCounter %s
2+
// REQUIRES: OS=macosx
3+
// REQUIRES: asserts
4+
5+
_ = MemoryLayout<Int>.size
6+
%for i in range(0, N):
7+
+ MemoryLayout<Int>.size
8+
%end
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: not %scale-test --begin 1 --end 3 --step 1 --select incrementScopeCounter %s
2+
// REQUIRES: OS=macosx
3+
// REQUIRES: asserts
4+
5+
func rdar33289839(s: String) -> String {
6+
return "test" + String(s)
7+
%for i in range(0, N):
8+
+ "test" + String(s)
9+
%end
10+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// RUN: not %scale-test --begin 2 --end 4 --step 1 --select incrementScopeCounter %s
2+
// REQUIRES: OS=macosx
3+
// REQUIRES: asserts
4+
5+
struct V3 {
6+
init(_ x: Int, _ y: Int, _ z: Int) {
7+
self.x = Float(x)
8+
self.y = Float(y)
9+
self.z = Float(z)
10+
}
11+
12+
init(_ x: Float, _ y: Float, _ z: Float) {
13+
self.x = x
14+
self.y = y
15+
self.z = z
16+
}
17+
18+
init(_ x: Double, _ y: Double, _ z: Double) {
19+
self.x = Float(x)
20+
self.y = Float(y)
21+
self.z = Float(z)
22+
}
23+
24+
var x: Float
25+
var y: Float
26+
var z: Float
27+
}
28+
29+
let a = [
30+
%for i in range(1, N):
31+
V3(0, 0, 0),
32+
%end
33+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: %target-typecheck-verify-swift -solver-expression-time-threshold=1
2+
// REQUIRES: tools-release,no_asserts
3+
4+
// Mixed Int/Double slow to emit diagnostics
5+
func rdar33476240(col: Int, row: Int, maxCol: Int, maxRow: Int) {
6+
let _ = (-(maxCol - 1) + (col * 2)) * 0.1
7+
// expected-error@-1 {{expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions}}
8+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// RUN: not %scale-test --begin 1 --end 3 --step 1 --select incrementScopeCounter %s
2+
// REQUIRES: OS=macosx
3+
// REQUIRES: asserts
4+
5+
let _ = 1
6+
%for i in range(0, N):
7+
| UInt32(${i}) << ${i}
8+
%end

0 commit comments

Comments
 (0)