Skip to content
This repository was archived by the owner on Apr 18, 2026. It is now read-only.
This repository was archived by the owner on Apr 18, 2026. It is now read-only.

Add facility for hiding values from the compiler #74

@dabrahams

Description

@dabrahams
/// 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: &copy) { assumePointeeIsWritten($0) }
  return copy
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions