-
Notifications
You must be signed in to change notification settings - Fork 10.5k
TypeLayout: Use AlignedGroups instead of ScalarLayouts #39053
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
TypeLayout: Use AlignedGroups instead of ScalarLayouts #39053
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5f63ca4
to
9cffbfb
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
9cffbfb
to
290c6dd
Compare
@swift-ci please test |
Build failed |
Build failed |
290c6dd
to
1e9127a
Compare
@swift-ci please smoke 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.
LGTM. Thank you!
1e9127a
to
332b4f7
Compare
Rebasing and cleaning up a bit. |
@swift-ci please smoke test |
Added ForceStructTypeLayouts. When enabled, IRGen will lower structs using the aligned group of TypeLayout rather than using TypeInfos. This potentially leads to a size increase as TypeInfos currently produce better code than the TypeLayout route.
If the Aligned Group is fixed sized and alignment, rather than doing an alignment computation at runtime, we compute the offset for each field and emit a GEP.
When generating TypeLayouts, rather than using a Scalar Layout, use an aligned struct so that we use the typelayout path rather than the typeinfo path when doing irgen.
Teach TypeLayout about when it can omit checking the enum tag and instead directly either ignore retaining/releasing the payload or retain/release it regardless of the enum tag. This ports to PO/NullableRefcounted/ForwardToPayload distinctions to TypeLayout.
332b4f7
to
b3c9316
Compare
@swift-ci please smoke test |
@swift-ci please test windows platform |
Windows build seems to be broken. Same test is failing in other PRs. |
The goal of these changes is to reduce the uses of getOrCreateScalarEntry which is a passthrough to the typeinfo system rather than using the typelayout system. Removing these uses should increase the visibility that the typelayout system has in the types that it is lowering and allow it to generate better code.
However, simply changing the included getOrCreateScalarEntries to getOrCreateAligned groups causes a significant size increase. The two main contributors were enums not implementing pod/nullablerefcount/forwardtopayload optimizations and structs doing alignment computations for each field.
This PR teach typelayout how to do the above and then swaps to using aligned group entries instead of scalar group entries. In my testing it brought the size increase down to within 1%, but it might be good to test it against more samples.