-
Notifications
You must be signed in to change notification settings - Fork 161
[CIR][CodeGen] Removed special handling for array of union #1780
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
base: main
Are you sure you want to change the base?
Conversation
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.
This looks good to me. The special handling for arrays of unions seems to have been off the mark.
Thanks for the review @andykaylor, I applied the requested changes. |
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.
Awesome!
Special handling for array of union was forcing all non-union C arrays to be emitted as CIR arrays, which differs from OG CodeGen, where some arrays are emitted as structs.
…e handling result
c33200a
to
c060df4
Compare
Rebased on top of latest rebase. |
@@ -1159,8 +1117,7 @@ class ConstExprEmitter | |||
|
|||
if (i == 0) | |||
CommonElementType = C.getType(); | |||
else if (isDesiredArrayOfUnionDirectly && | |||
C.getType() != CommonElementType) | |||
else if (C.getType() != CommonElementType) |
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.
It's worth adding a comment here to briefly mention how we deviate from OG (absence of isDesiredArrayOfUnionDirectly
)
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.
From when I looked into this: this code isn't why we deviate from OG CodeGen. We deviate because OG 'optimizes' emission of structs with homogeneous field types to an array of the field type. I couldn't find a good heuristic for exactly when they do/don't do that so I didn't include a fix and just reverted the changes (to get rid of lowering crashes). I think a comment about that here may lead folks down the wrong road to fixing the issue, because it should to be handled when we lower to LLVM, not when we generate CIR.
I noticed a linux failure, is that related? |
Looks like they're all errors in clang-tidy:
I can look into it in the morning. |
Special handling for array of unions was forcing all non-union C arrays to be emitted as CIR arrays, which differs from OG CodeGen, where array may be emitted as LLVM struct.
Closes #1315