Skip to content

Commit 53f2660

Browse files
committed
benchmarks: Convert the PartialApplyDynamicType into a lit test
This benchmark was added to test if the compiler crashes. For some reason it was added as benchmark and not as lit test. It has no value as benchmark anyway because the compiler optimizes away pretty much everything.
1 parent 98f3961 commit 53f2660

File tree

4 files changed

+29
-45
lines changed

4 files changed

+29
-45
lines changed

benchmark/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ set(SWIFT_BENCH_MODULES
113113
single-source/ObserverUnappliedMethod
114114
single-source/OpaqueConsumingUsers
115115
single-source/OpenClose
116-
single-source/PartialApplyDynamicType
117116
single-source/Phonebook
118117
single-source/PointerArithmetics
119118
single-source/PolymorphicCalls

benchmark/single-source/PartialApplyDynamicType.swift

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

benchmark/utils/main.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ import ObserverPartiallyAppliedMethod
103103
import ObserverUnappliedMethod
104104
import OpaqueConsumingUsers
105105
import OpenClose
106-
import PartialApplyDynamicType
107106
import Phonebook
108107
import PointerArithmetics
109108
import PolymorphicCalls
@@ -267,7 +266,6 @@ registerBenchmark(ObserverPartiallyAppliedMethod)
267266
registerBenchmark(ObserverUnappliedMethod)
268267
registerBenchmark(OpaqueConsumingUsers)
269268
registerBenchmark(OpenClose)
270-
registerBenchmark(PartialApplyDynamicType)
271269
registerBenchmark(Phonebook)
272270
registerBenchmark(PointerArithmetics)
273271
registerBenchmark(PolymorphicCalls)
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// RUN: %target-swift-frontend -O -emit-ir %s
2+
3+
// Test that this does not crash
4+
5+
protocol P {
6+
func f(_ i: Int) -> Int
7+
}
8+
9+
func g<T: P>(_ t: T) -> ((T) -> (Int) -> Int) {
10+
let f = { type(of: t).f($0) }
11+
return f
12+
}
13+
14+
class C: P {
15+
func f(_ i: Int) -> Int {
16+
return i + 1
17+
}
18+
}
19+
20+
let c = C()
21+
22+
public func test_PartialApplyDynamicType() -> Int {
23+
var result = 0
24+
for _ in 1...100000 {
25+
result += g(c)(c)(1)
26+
}
27+
return result
28+
}
29+

0 commit comments

Comments
 (0)