-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Optimizer: support statically initialized Atomic
and Mutex
globals
#83505
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
Optimizer: support statically initialized Atomic
and Mutex
globals
#83505
Conversation
@swift-ci test |
@swift-ci apple silicon benchmark |
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.
❤️ 🎉
case let injectEnum as InjectEnumAddrInst: | ||
if injectEnum.element.hasAssociatedValues { | ||
if !injectEnum.operand.value.type.isLoadable(in: injectEnum.parentFunction) { | ||
// TODO: we don't support non-loadable enum cases with payload yet, because IRGen support is missing. |
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.
What IRGen support is missing here?
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.
FixedTypeInfo (= used for non-loadable types) is missing the ability to pack a payload into an enum.
I added this in a comment.
It would also be nice to see if this patch allows statically initializing |
which allows e.g. eliminating dead `Atomic` values
…er` when generating a value constructor for an empty non-copyable type `zeroInitializer` is blocking optimizations. It is not needed because the constructor will initialize the memory anyway. We only need to tell mandatory passes that this memory should be treated as initialized.
…tType` in `Type`
…l.hasAssociatedValues`
763d3a4
to
6149e2e
Compare
… struct with `@_rawLayout` Even if the global declaration is a `let`. Raw-layout storage may be mutated even for let-variables. Treating such variables as non-let ensures that optimization don't assume that they are not mutated.
…ialized globals Just use the same method to create the zero initializer constant as in `emitBuiltinCall`.
…ut` types, like `Atomic` Look through `@_rawLayout` projections, which "type casts" a raw-layout struct to it's content, which must match the like-type of the raw-layout, e.g. ``` @_rawLayout(like: T) struct S {} %2 = builtin "addressOfRawLayout"<S>(%1 : $*S) : $Builtin.RawPointer %3 = pointer_to_address %2 to $*T ```
TODO: we don't support non-loadable enum cases with payload, yet, because IRGen support is missing.
6149e2e
to
eaf38da
Compare
Atomic
globalsAtomic
and Mutex
globals
This is a good point and in fact there was missing a small thing to make this happen. I fixed it and added a test |
@swift-ci test |
For example:
This PR adds support for
@_rawLayout
structs and non-loadable types in InitializeStaticGlobals.