-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[stdlib] BitwiseCopyable loadUnaligned overloads. #70248
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
Conversation
a46d81d
to
dbc63e7
Compare
@swift-ci please test |
I like this approach. The standard library team should review to be sure I'm not missing some problem. |
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. I wonder if we can use Builtin.loadRaw
in the unconstrained versions as well, since every version of loadUnaligned
is always-emit-into-client.
@@ -473,8 +483,6 @@ public struct UnsafeRawPointer: _Pointer { | |||
) | |||
return temporary.pointee | |||
} | |||
//FIXME: reimplement with `loadRaw` when supported in SIL (rdar://96956089) | |||
// e.g. Builtin.loadRaw((self + offset)._rawValue) | |||
} |
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 Builtin.loadRaw
be used for the version that doesn't have the generic constraint?
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.
Unfortunately no--we need to generate a direct call to memcpy rather than to a value witness; the compiler needs to know the type is BitwiseCopyable in order to know doing so is correct.
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.
I see. Nice to know!
If an archetype conforms to the protocol, use the new TypeInfo. This allows clients to use code in the stdlib that's built with BitwiseCopyable.
The new overloads will make use the new BitwiseCopyableArchetypeTypeInfo to avoid the extra copy that is currently done.
dbc63e7
to
b7f5171
Compare
@swift-ci please test |
@swift-ci please test linux platform |
1 similar comment
@swift-ci please test linux platform |
The new overloads will make use of the new
BitwiseCopyableArchetypeTypeInfo
to avoid the extra copy that is currently done.