-
Notifications
You must be signed in to change notification settings - Fork 225
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
feat(brillig): SSA globals code gen #7021
base: master
Are you sure you want to change the base?
Conversation
Co-authored-by: jfecher <[email protected]>
The remaining regressions look to be due to dead globals not being removed. Will have a PR shortly. |
I tried building off master originally but it was a lot easier to test, building off this branch. The work can be seen here in #7081.
The globals DIE in #7081 is also not going to get rid of these extra instructions we see here. The affect on programs that make more meaningful usage of globals across functions can still be seen.
|
I look to be getting failures post AztecProtocol/aztec-packages#10605. Working on resolving it now. EDIT: Ah it is all |
I assume that this is from the roots global. This isn't used in brillig code currently so I imagine this would be solved by the die pass PR That said, as we know all of the globals at compile time we should be able to expand the space allocated as necessary. If so can you create a follow up issue? |
Yeah I'll make an issue for the max global space to be determined by the program rather than a hardcoded value. |
@@ -32,28 +32,38 @@ use super::brillig_fn::FunctionContext; | |||
use super::constant_allocation::InstructionLocation; | |||
|
|||
/// Generate the compilation artifacts for compiling a function into brillig bytecode. | |||
pub(crate) struct BrilligBlock<'block> { | |||
pub(crate) function_context: &'block mut FunctionContext, | |||
pub(crate) struct BrilligBlock<'block, 'global, Registers: RegisterAllocator> { |
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.
Do we need two lifetimes here? I'd expect that the globals would outlive 'block
anyway so we can just reuse that lifetime.
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.
Huh, not sure why I put them on the FunctionContext
, good point. I think with how I have it now with the globals inside of FunctionContext
I cannot avoid the second lifetime, but I will move it out of there and put it directly on BrilligBlock
.
Description
Problem*
Resolves #6801
Summary*
Implements globals from SSA in Brillig gen. We create a new memory space
GlobalSpace
at compile time. Globals are declared in the global space and the linker is then used to connect these with our SSA functions. When converting SSA values we check whether we have a global and if so, look for the appropriate register that keys into the appropriate slot in the global space.Additional Context
Some slight regressions are expected. Some reasons for this are laid out here #7021 (comment).
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.