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] Add codegen for global compound literals #454

Merged
merged 1 commit into from
Feb 8, 2024

Conversation

YazZz1k
Copy link
Contributor

@YazZz1k YazZz1k commented Feb 7, 2024

This PR adds support for global compound literals.
The implementation is almost the same as in original codegen. But the original codegen can reuse the value of emitted compound literal global variable in case then the init expression of new variable and this variable are the same.
It's easy to implement this feature. But I can't find any test-case then this feature will be applied. So I decided to ignore this optimization opportunity to avoid mistakes.

@YazZz1k YazZz1k changed the title CIR][CIRGen] Add codegen for global compound literals WIP [CIR][CIRGen] Add codegen for global compound literals Feb 7, 2024
@bcardosolopes
Copy link
Member

Nice, thanks! Is there any reason why this is a Draft? If you are unsure about some specific part, it'd be good to mention it in the summary/description, so we can better help.

Can you add LLVM lowering as part of this PR? I'm a bit curious how the empty #cir.zero array will fits the overall lowering story here.

@YazZz1k YazZz1k marked this pull request as ready for review February 8, 2024 09:41
@YazZz1k YazZz1k changed the title WIP [CIR][CIRGen] Add codegen for global compound literals [CIR][CIRGen] Add codegen for global compound literals Feb 8, 2024
@YazZz1k
Copy link
Contributor Author

YazZz1k commented Feb 8, 2024

Nice, thanks! Is there any reason why this is a Draft? If you are unsure about some specific part, it'd be good to mention it in the summary/description, so we can better help.

Can you add LLVM lowering as part of this PR? I'm a bit curious how the empty #cir.zero array will fits the overall lowering story here.

Sorry for the empty description. I added llvm ir checks to test.
The folowing transforms will be applied:
      #cir.zero : !cir.array<!s32i x 0> -> %0 = cir.llvmir.zeroinit : !llvm.array<0 x i32> ->
      [0 x i32] zeroinitializer.
it's fully concides with the original codegen. So this shouldn't be an issue.

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.

Thanks! LGTM

@bcardosolopes bcardosolopes merged commit db2e245 into llvm:main Feb 8, 2024
8 checks passed
lanza pushed a commit that referenced this pull request Mar 23, 2024
This PR adds support for global compound literals. 
The implementation is almost the same as in original codegen. But the
original codegen can reuse the value of emitted compound literal global
variable in case then the init expression of new variable and this
variable are the same.
It's easy to implement this feature. But I can't find any test-case then
this feature will be applied. So I decided to ignore this optimization
opportunity to avoid mistakes.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Mar 24, 2024
This PR adds support for global compound literals. 
The implementation is almost the same as in original codegen. But the
original codegen can reuse the value of emitted compound literal global
variable in case then the init expression of new variable and this
variable are the same.
It's easy to implement this feature. But I can't find any test-case then
this feature will be applied. So I decided to ignore this optimization
opportunity to avoid mistakes.
lanza pushed a commit that referenced this pull request Apr 29, 2024
This PR adds support for global compound literals.
The implementation is almost the same as in original codegen. But the
original codegen can reuse the value of emitted compound literal global
variable in case then the init expression of new variable and this
variable are the same.
It's easy to implement this feature. But I can't find any test-case then
this feature will be applied. So I decided to ignore this optimization
opportunity to avoid mistakes.
lanza pushed a commit that referenced this pull request Apr 29, 2024
This PR adds support for global compound literals.
The implementation is almost the same as in original codegen. But the
original codegen can reuse the value of emitted compound literal global
variable in case then the init expression of new variable and this
variable are the same.
It's easy to implement this feature. But I can't find any test-case then
this feature will be applied. So I decided to ignore this optimization
opportunity to avoid mistakes.
eZWALT pushed a commit to eZWALT/clangir that referenced this pull request Apr 29, 2024
This PR adds support for global compound literals. 
The implementation is almost the same as in original codegen. But the
original codegen can reuse the value of emitted compound literal global
variable in case then the init expression of new variable and this
variable are the same.
It's easy to implement this feature. But I can't find any test-case then
this feature will be applied. So I decided to ignore this optimization
opportunity to avoid mistakes.
lanza pushed a commit that referenced this pull request Apr 29, 2024
This PR adds support for global compound literals.
The implementation is almost the same as in original codegen. But the
original codegen can reuse the value of emitted compound literal global
variable in case then the init expression of new variable and this
variable are the same.
It's easy to implement this feature. But I can't find any test-case then
this feature will be applied. So I decided to ignore this optimization
opportunity to avoid mistakes.
bruteforceboy pushed a commit to bruteforceboy/clangir that referenced this pull request Oct 2, 2024
This PR adds support for global compound literals.
The implementation is almost the same as in original codegen. But the
original codegen can reuse the value of emitted compound literal global
variable in case then the init expression of new variable and this
variable are the same.
It's easy to implement this feature. But I can't find any test-case then
this feature will be applied. So I decided to ignore this optimization
opportunity to avoid mistakes.
Hugobros3 pushed a commit to shady-gang/clangir that referenced this pull request Oct 2, 2024
This PR adds support for global compound literals.
The implementation is almost the same as in original codegen. But the
original codegen can reuse the value of emitted compound literal global
variable in case then the init expression of new variable and this
variable are the same.
It's easy to implement this feature. But I can't find any test-case then
this feature will be applied. So I decided to ignore this optimization
opportunity to avoid mistakes.
keryell pushed a commit to keryell/clangir that referenced this pull request Oct 19, 2024
This PR adds support for global compound literals.
The implementation is almost the same as in original codegen. But the
original codegen can reuse the value of emitted compound literal global
variable in case then the init expression of new variable and this
variable are the same.
It's easy to implement this feature. But I can't find any test-case then
this feature will be applied. So I decided to ignore this optimization
opportunity to avoid mistakes.
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