-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
@_noLocksFeature → attributes: The @_noLocks attributeFeature → attributes: The @_noLocks attributeSILattributesFeature: Declaration and type attributesFeature: Declaration and type attributesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfperformanceswift 6.0unexpected errorBug: Unexpected errorBug: Unexpected error
Description
Description
The new Atomic type cannot be used with @_noLocks since a simple usage reports a violation. It seems that the issue is in the implementation of Atomic load and the use Builtin.atomicload_{} family of functions.
A simplified code sample is available below. Required settings:
swiftSettings: [
.unsafeFlags(["-disable-availability-checking"]),
.enableExperimentalFeature("StaticExclusiveOnly"),
.enableExperimentalFeature("RawLayout"),
.enableExperimentalFeature("BuiltinModule")
]
Reproduction
import Builtin
public struct MyAtomic: ~Copyable {
var rawAddress: Builtin.RawPointer {
Builtin.unprotectedAddressOfBorrow(self)
}
}
extension MyAtomic {
@_noLocks
public func load(ordering: AtomicLoadOrdering) -> Int {
let result = Builtin.atomicload_monotonic_Int64(rawAddress) // error: this code pattern can cause locking
return 1
}
}Expected behavior
Atomic load doesn't cause locking and performance annotation doesn't report violation.
Environment
Apple Swift version 6.0-dev (LLVM 57177aa1b91540b, Swift 3889ede)
Target: arm64-apple-macosx14.0
Additional information
cc @eeckstein @Azoy
Metadata
Metadata
Assignees
Labels
@_noLocksFeature → attributes: The @_noLocks attributeFeature → attributes: The @_noLocks attributeSILattributesFeature: Declaration and type attributesFeature: Declaration and type attributesbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfThe Swift compiler itselfperformanceswift 6.0unexpected errorBug: Unexpected errorBug: Unexpected error