-
Notifications
You must be signed in to change notification settings - Fork 229
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
chore(refactor): Remove globals field on Ssa object and use only the shared globals graph #7156
base: master
Are you sure you want to change the base?
Conversation
return brillig; | ||
} | ||
|
||
let func_id = brillig_reachable_function_ids |
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.
What is this func_id
? Is it this Function
?
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.
No it is just the first function from brillig_reachable_function_ids
. The globals graph is computed a single time and shared among all functions (see #7040), so we can use any func id here. I switched to using self.main_id
to be more explicit.
@@ -25,7 +26,8 @@ impl Ssa { | |||
let mut context = Context::default(); | |||
context.populate_functions(&self.functions); | |||
for function in self.functions.values_mut() { | |||
context.normalize_ids(function, &self.globals); | |||
let globals = (*function.dfg.globals).clone(); |
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.
Is this clone
before passing a reference avoidable?
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 is not as GlobalsGraph
cannot be moved out of Arc
as it does not implement Copy
. I have moved it out of the loop though.
Description
Problem*
No issue, but just a general refactor. We have repeated declaration of globals (the shared
globals: Arc<GlobalsGraph>
field onDataFlowGraph
and theglobals: Function
onSsa
). We need the globals field on the DFG for resolving constants #7040. However, the globals field on theSsa
object is only used by the SSA printer and the brillig codegen. Which in both case could use the globals graph from any function.Summary*
I removed
globals: Function
fromSsa
and use the globals graph from a function in the places where theSsa
field was being used.Certain interfaces such as the printer and Brillig codegen still utilize the
DataFlowGraph
type so some conversions from aGlobalsGraph
to aDataFlowGraph
were necessary to avoid larger changes.Additional Context
Documentation*
Check one:
PR Checklist*
cargo fmt
on default settings.