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

[CIR][CodeGen] Adds union padding #1289

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

gitoleg
Copy link
Collaborator

@gitoleg gitoleg commented Jan 23, 2025

This PR adds padding for union type, which is necessary in some cases (e.g. proper offset computation for an element of an array).

The previous discussion is here #1281

The idea is to add a notion about padding in the StructType in the same fashion as it's done for packed structures - as a bool argument in the constructor.

Now we can compute the proper union type size as a size of the largest element + size of padding type.

There are some downsides though - I had to add this padded word in many places. So take a look please!
There are many tests fixed and one new - union-padding

Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Overall looks good, you could go ahead and remove the lines you commented (and FIXME/TODOs that don't apply anymore).

Seems like even though it's adding the padded bit to regular structs (as updated testcases show), it's not using that information to do anything for them, is that true or did I miss something?

@gitoleg gitoleg marked this pull request as ready for review January 29, 2025 13:46
@gitoleg gitoleg requested a review from lanza as a code owner January 29, 2025 13:46
@gitoleg
Copy link
Collaborator Author

gitoleg commented Jan 29, 2025

@bcardosolopes updated!

Seems like even though it's adding the padded bit to regular structs (as updated testcases show), it's not using that information to do anything for them, is that true or did I miss something?

It's true! Btw, maybe it will be good idea to use this padded for unions only? unless someone won't need something else? Because it looks a bit weird, especially for classes on my taste

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