mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
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.
This commit is contained in:
@@ -324,11 +324,13 @@ public func someProtocolFactory() -> SomeProtocol { return MyStruct() }
|
||||
// It's important that this function is in another module than the tests
|
||||
// which are using it.
|
||||
@inline(never)
|
||||
@_semantics("optimize.no.crossmodule")
|
||||
public func blackHole<T>(_ x: T) {
|
||||
}
|
||||
|
||||
// Return the passed argument without letting the optimizer know that.
|
||||
@inline(never)
|
||||
@_semantics("optimize.no.crossmodule")
|
||||
public func identity<T>(_ x: T) -> T {
|
||||
return x
|
||||
}
|
||||
@@ -337,12 +339,15 @@ public func identity<T>(_ x: T) -> T {
|
||||
// It's important that this function is in another module than the tests
|
||||
// which are using it.
|
||||
@inline(never)
|
||||
@_semantics("optimize.no.crossmodule")
|
||||
public func getInt(_ x: Int) -> Int { return x }
|
||||
|
||||
// The same for String.
|
||||
@inline(never)
|
||||
@_semantics("optimize.no.crossmodule")
|
||||
public func getString(_ s: String) -> String { return s }
|
||||
|
||||
// The same for Substring.
|
||||
@inline(never)
|
||||
@_semantics("optimize.no.crossmodule")
|
||||
public func getSubstring(_ s: Substring) -> Substring { return s }
|
||||
|
||||
Reference in New Issue
Block a user