swift-benchmark
swift-benchmark copied to clipboard
Add facility for hiding values from the compiler
/// Returns `x`, preventing its value from being statically known by the optimizer.
@inline(__always)
fileprivate func hideValue<T>(_ x: T) -> T {
@_optimize(none)
func assumePointeeIsWritten<T>(_ x: UnsafeMutablePointer<T>) {}
var copy = x
withUnsafeMutablePointer(to: ©) { assumePointeeIsWritten($0) }
return copy
}