-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[IRGen] Use memcpy for BitwiseCopyable archetypes. #70112
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
[IRGen] Use memcpy for BitwiseCopyable archetypes. #70112
Conversation
4de6a96
to
bc95402
Compare
bc95402
to
cfae49a
Compare
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. This just needs to line up with @kavon's plans for surfacing BitwiseCopyable and we'll probably need to make it available under a production feature before libraries, like swift-collections, can start building on top of it.
Let's use the PR mentioned above #69938 that surfaces the protocol and adds a feature flag to discuss those aspects. |
cfae49a
to
dfb1200
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you also add for a protocol that inherits from BitwiseCopyable?
c8cbefe
to
7be9457
Compare
Yep, added an analogous test for an unaligned load where the archetype is constrained to conform to a protocol derived from BitwiseCopyable. |
@swift-ci please test |
7be9457
to
ce2b40d
Compare
Similar to the existing variant which takes a fixed size, the new variant which takes a dynamic size digs the relevant address and alignment values out of the Address struct and passes them along.
Besides being an optimization, using memcpy directly rather than a value witness is required in order to interact with unaligned instances of such types: the value witness functions expect their arguments to be aligned. rdar://96919870
ce2b40d
to
fef7c77
Compare
@swift-ci please test |
Based on #69938 . This PR adds two new commits.
Besides being an optimization, using memcpy directly rather than a value witness is required in order to interact with unaligned instances of such types: the value witness functions expect their arguments to be aligned.
rdar://96919870