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][CIRGen] Improve emission for array of unions #1236

Merged
merged 3 commits into from
Jan 6, 2025

Conversation

ChuanqiXu9
Copy link
Member

Close #1185

The patch itself seems slightly ad-hoc. As the issue tracked by #1178, the fundamental solution may be to introduce two type systems to solve the inconsistent semantics for Union between LLVM IR and CIR. This will be great to handle other inconsistent semantics between LLVM IR and CIR if any.

Back to the patch itself, although the code looks not good initially to me too. But I feel it may be a good workaround since clang/test/CIR/Lowering/union-array.c is an example for array of unions directly and clang/test/CIR/Lowering/nested-union-array.c gives an example for array of unions indirectly (array of structs which contain unions). So I feel we've already covered all the cases.

And generally it should be good to use some simple and solid workaround before we introduce the formal full solution.

Close llvm#1185

The patch itself seems slightly ad-hoc. As the issue tracked by
llvm#1178, the fundamental solution
may be to introduce two type systems to solve the inconsistent semantics
for Union between LLVM IR and CIR. This will be great to handle other
inconsistent semantics between LLVM IR and CIR if any.

Back to the patch itself, although the code looks not good initially to
me too. But I feel it may be a good workaround since
clang/test/CIR/Lowering/union-array.c is an example for array of unions
directly and clang/test/CIR/Lowering/nested-union-array.c gives an
example for array of unions indirectly (array of structs which contain
unions). So I feel we've already covered all the cases.

And generally it should be good to use some simple and solid workaround
before we introduce the formal full solution.
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.

I think it's fine to have a workaround here, as we collect those it provides us more testcases we should not regress when going for the more general approach.

clang/test/CIR/Lowering/union-array.c Outdated Show resolved Hide resolved
clang/lib/CIR/CodeGen/CIRGenExprConst.cpp Show resolved Hide resolved
@bcardosolopes bcardosolopes changed the title [CIR] [CIRGen] Handle CIR Gen for array of unions [CIR][CIRGen] Handle CIR Gen for array of unions Dec 17, 2024
@bcardosolopes bcardosolopes changed the title [CIR][CIRGen] Handle CIR Gen for array of unions [CIR][CIRGen] Improve emission for array of unions Dec 17, 2024
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.

A few more nits and good to go

clang/lib/CIR/CodeGen/CIRGenExprConst.cpp Outdated Show resolved Hide resolved
clang/lib/CIR/CodeGen/CIRGenExprConst.cpp Outdated Show resolved Hide resolved
clang/lib/CIR/CodeGen/CIRGenExprConst.cpp Show resolved Hide resolved
@bcardosolopes bcardosolopes merged commit e3f166b into llvm:main Jan 6, 2025
6 checks passed
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.

Lowering to LLVM fails for constant array of unions with unequal initializer types
2 participants