Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@_noLocks doesn't work with ~Copyable types #73582

Closed
jcavar opened this issue May 11, 2024 · 5 comments · Fixed by #73611
Closed

@_noLocks doesn't work with ~Copyable types #73582

jcavar opened this issue May 11, 2024 · 5 comments · Fixed by #73611
Assignees
Labels
attributes Feature: Declaration and type attributes bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself @_noLocks Feature → attributes: The @_noLocks attribute noncopyable struct/enum Feature → declarations: Noncopyable value type declarations SILOptimizer Area → compiler: SIL optimization passes swift 6.0 unexpected error Bug: Unexpected error

Comments

@jcavar
Copy link

jcavar commented May 11, 2024

Description

A simple usage of @_noLocks fails to compile when using ~Copyable types. I am not sure if this is genuine issue or a bug in performance annotation implementation.

Reproduction

// this code performs reference counting operations which can cause locking
struct Test: ~Copyable {
}

@_noLocks
@_noAllocation
func test() {
    Test()
}

Expected behavior

Code compiles and doesn't perform reference counting

Environment

It fails on both 5.10 and nightly snapshots

Additional information

No response

cc @eeckstein

@jcavar jcavar added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels May 11, 2024
@tbkka
Copy link
Contributor

tbkka commented May 13, 2024

CC: @eeckstein @kavon

@tbkka
Copy link
Contributor

tbkka commented May 13, 2024

@jcavar The code you've written -- without any annotations at all -- should not perform any reference counting because there are no class values.

@eeckstein eeckstein self-assigned this May 14, 2024
eeckstein added a commit to eeckstein/swift that referenced this issue May 14, 2024
An initializing store is not a copy and therefore doesn't perform ref counting operations

Fixes a false performance error when using non-copyable types.
apple#73582
@eeckstein
Copy link
Member

Fix: #73611

eeckstein added a commit to eeckstein/swift that referenced this issue May 15, 2024
An initializing store is not a copy and therefore doesn't perform ref counting operations

Fixes a false performance error when using non-copyable types.
apple#73582
@eeckstein
Copy link
Member

6.0: #73637

@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler in itself SILOptimizer Area → compiler: SIL optimization passes attributes Feature: Declaration and type attributes @_noLocks Feature → attributes: The @_noLocks attribute swift 6.0 unexpected error Bug: Unexpected error noncopyable struct/enum Feature → declarations: Noncopyable value type declarations and removed triage needed This issue needs more specific labels labels May 16, 2024
@jcavar
Copy link
Author

jcavar commented May 28, 2024

Thank you @eeckstein! I've downloaded the latest Swift 6 toolchain and don't get the error anymore.

I do get a similar issue further down the line that I described here:

#73951

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
attributes Feature: Declaration and type attributes bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself @_noLocks Feature → attributes: The @_noLocks attribute noncopyable struct/enum Feature → declarations: Noncopyable value type declarations SILOptimizer Area → compiler: SIL optimization passes swift 6.0 unexpected error Bug: Unexpected error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants