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] Lower nested local constant alloca #1261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Lancern
Copy link
Member

@Lancern Lancern commented Dec 29, 2024

This PR adds support for lowering local constants in nested scopes, including those in nested loops.

For those constant allocas in non-loop inner scopes, this PR keeps their constant flags during alloca hoisting. LLVM lowering would correctly emit necessary invariant metadata for those allocas.

For those constant allocas in a loop, this PR introduces a new operation cir.invariant_group that marks the beginning of the lifetime of the constant objects. This operation is put at the location of the alloca operation before hoisting them. This PR updates LLVM lowering to emit the necessary invariant metadata when loading and storing through such pointers.

This PR takes care of the special case where the constant alloca represents a variable declared in the condition part of a while loop. In such a case, this PR removes the constant flag on the alloca operation when hositing them.

This patch adds support for lowering local constants in nested scopes, including
those in nested loops.

For those constant allocas in non-loop inner scopes, this patch keeps their
constant flags during alloca hoisting. LLVM lowering would correctly emit
necessary invariant metadata for those allocas.

For those constant allocas in a loop, this patch introduces a new operation
`cir.invariant_group` that marks the beginning of the lifetime of the constant
objects. This operation is put at the location of the alloca operation before
hoisting them. This patch updates LLVM lowering to emit the necessary invariant
metadata when loading and storing through such pointers.

This patch takes care of the special case where the constant alloca represents
a variable declared in the condition part of a while loop. In such a case, this
patch removes the constant flag on the alloca operation when hositing them.
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.

1 participant