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

Increase alginment for packed structures #362

Merged
merged 1 commit into from
Mar 30, 2022
Merged

Increase alginment for packed structures #362

merged 1 commit into from
Mar 30, 2022

Conversation

josephlr
Copy link
Contributor

While both TaskStateSegment and DescriptorTablePointer can't have their
normal C alignment due to their definition. However, this doesn't mean
their alignment has to be 1.

This PR sets their alignment to be the max possible while still
preserving their ABI definied structure. I added some tests to make sure
there is not a regression.

This can also result in more efficient code generation on platofrms
without unalgined loads. https://rust.godbolt.org/z/EPbbMxeq1

Signed-off-by: Joe Richey [email protected]

While both TaskStateSegment and DescriptorTablePointer can't have their
normal C alignment due to their definition. However, this doesn't mean
their alignment has to be `1`.

This PR sets their alignment to be the max possible while still
preserving their ABI definied structure. I added some tests to make sure
there is not a regression.

This can also result in more efficient code generation on platofrms
without unalgined loads. https://rust.godbolt.org/z/EPbbMxeq1

Signed-off-by: Joe Richey <[email protected]>
Copy link
Member

@Freax13 Freax13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, I never realized that there's a reason to prefer an alignment number greater than 1 for packed, very cool!

@josephlr josephlr merged commit 6ae5b6a into master Mar 30, 2022
@josephlr josephlr deleted the align branch March 30, 2022 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants