Skip to content

Commit 1fceeab

Browse files
committed
benchmarks: prevent some functions from being cross-module optimized.
Function bodies of `blackHole`, `identity`, etc. must not be visible in the benchmark modules. Enabling CMO by default broke this. Since then we need to explicitly exclude those functions from cross-module-optimization.
1 parent fb65284 commit 1fceeab

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

benchmark/utils/TestsUtils.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,11 +324,13 @@ public func someProtocolFactory() -> SomeProtocol { return MyStruct() }
324324
// It's important that this function is in another module than the tests
325325
// which are using it.
326326
@inline(never)
327+
@_semantics("optimize.no.crossmodule")
327328
public func blackHole<T>(_ x: T) {
328329
}
329330

330331
// Return the passed argument without letting the optimizer know that.
331332
@inline(never)
333+
@_semantics("optimize.no.crossmodule")
332334
public func identity<T>(_ x: T) -> T {
333335
return x
334336
}
@@ -337,12 +339,15 @@ public func identity<T>(_ x: T) -> T {
337339
// It's important that this function is in another module than the tests
338340
// which are using it.
339341
@inline(never)
342+
@_semantics("optimize.no.crossmodule")
340343
public func getInt(_ x: Int) -> Int { return x }
341344

342345
// The same for String.
343346
@inline(never)
347+
@_semantics("optimize.no.crossmodule")
344348
public func getString(_ s: String) -> String { return s }
345349

346350
// The same for Substring.
347351
@inline(never)
352+
@_semantics("optimize.no.crossmodule")
348353
public func getSubstring(_ s: Substring) -> Substring { return s }

0 commit comments

Comments
 (0)