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][Lowering] Lower unions #230

Merged
merged 4 commits into from
Aug 28, 2023

Conversation

sitio-couto
Copy link
Collaborator

@sitio-couto sitio-couto commented Aug 11, 2023

Stack from ghstack (oldest at bottom):

Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

[ghstack-poisoned]
sitio-couto added a commit that referenced this pull request Aug 11, 2023
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: e2d7031104cc9c70995f5ab2f5b330a937fcad8e
Pull Request resolved: #230
}
}

return largestTy;
Copy link
Member

Choose a reason for hiding this comment

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

Just like we do for mutable std::optional<bool> padded{}; and others in computeSizeAndAlignment, I think we should only compute the type once and re-use the value in subsequent calls. In this case it's even easier because an empty mlir::Type is enough to track "not done yet".

Also, please do all computation in computeSizeAndAlignment and make getLargestMember check if the Type is valid, if not, call in computeSizeAndAlignment and return the said type.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@bcardosolopes applied

clang/lib/CIR/Dialect/IR/CIRTypes.cpp Outdated Show resolved Hide resolved
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

[ghstack-poisoned]
sitio-couto added a commit that referenced this pull request Aug 22, 2023
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 791a944c5df3103c5671ba061fe4c7c3a56317fa
Pull Request resolved: #230
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

[ghstack-poisoned]
sitio-couto added a commit that referenced this pull request Aug 23, 2023
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 88b2927a5a9c094e6d948148e68079659f79cdd2
Pull Request resolved: #230
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.

LGTM

Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

[ghstack-poisoned]
sitio-couto added a commit that referenced this pull request Aug 28, 2023
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: #230
@sitio-couto sitio-couto merged commit 435879a into gh/sitio-couto/50/base Aug 28, 2023
sitio-couto added a commit that referenced this pull request Aug 28, 2023
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: #230
@sitio-couto sitio-couto deleted the gh/sitio-couto/50/head branch August 28, 2023 23:47
lanza pushed a commit that referenced this pull request Oct 27, 2023
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: #230
lanza pushed a commit that referenced this pull request Dec 20, 2023
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: #230
lanza pushed a commit that referenced this pull request Jan 29, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: #230
lanza pushed a commit to lanza/llvm-project that referenced this pull request Feb 8, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: llvm/clangir#230
lanza pushed a commit that referenced this pull request Mar 23, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: #230
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Mar 24, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: llvm#230
lanza pushed a commit that referenced this pull request Apr 29, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: #230
lanza pushed a commit that referenced this pull request Apr 29, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: #230
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Apr 29, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: llvm#230
lanza pushed a commit that referenced this pull request Apr 29, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: #230
pysuxing pushed a commit to pysuxing/llvm-project that referenced this pull request Jul 17, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: llvm/clangir#230
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: llvm#230
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: llvm#230
lanza pushed a commit that referenced this pull request Nov 5, 2024
Converts a union to a struct containing only its largest element.
GetMemberOp for unions is lowered as bitcasts instead of GEPs, since
union members share the same address space.

ghstack-source-id: 744ac312675b8f3225ccc459fcd09474bcfcfe81
Pull Request resolved: #230
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