Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use fxhash::{FxHashMap as HashMap, FxHashSet as HashSet};

use super::brillig_block::BrilligBlock;
use super::{BrilligVariable, Function, FunctionContext, ValueId};
use crate::ssa::ir::call_graph::CallGraph;
use crate::ssa::ssa_gen::Ssa;
use crate::{
brillig::{
Brillig, BrilligOptions, ConstantAllocation, DataFlowGraph, FunctionId, Label,
Expand Down Expand Up @@ -55,11 +57,12 @@ pub(crate) type ConstantCounterMap = HashMap<(FieldElement, NumericType), usize>

impl BrilligGlobals {
pub(crate) fn new(
functions: &BTreeMap<FunctionId, Function>,
ssa: &Ssa,
mut used_globals: HashMap<FunctionId, HashSet<ValueId>>,
main_id: FunctionId,
) -> Self {
let brillig_entry_points = get_brillig_entry_points(functions, main_id);
let call_graph = CallGraph::from_ssa(ssa);
let brillig_entry_points = get_brillig_entry_points(&ssa.functions, main_id, &call_graph);

let mut hoisted_global_constants: HashMap<FunctionId, ConstantCounterMap> =
HashMap::default();
Expand All @@ -70,14 +73,14 @@ impl BrilligGlobals {
Self::mark_globals_for_hoisting(
&mut hoisted_global_constants,
*entry_point,
&functions[entry_point],
&ssa.functions[entry_point],
);

for inner_call in entry_point_inner_calls.iter() {
Self::mark_globals_for_hoisting(
&mut hoisted_global_constants,
*entry_point,
&functions[inner_call],
&ssa.functions[inner_call],
);

let inner_globals = used_globals
Expand Down Expand Up @@ -285,6 +288,7 @@ impl Brillig {
(artifact, function_context.ssa_value_allocations, globals_size, hoisted_global_constants)
}
}

#[cfg(test)]
mod tests {
use acvm::{
Expand Down
3 changes: 1 addition & 2 deletions compiler/noirc_evaluator/src/brillig/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,7 @@ impl Ssa {
return brillig;
}

let mut brillig_globals =
BrilligGlobals::new(&self.functions, used_globals_map, self.main_id);
let mut brillig_globals = BrilligGlobals::new(self, used_globals_map, self.main_id);

// SSA Globals are computed once at compile time and shared across all functions,
// thus we can just fetch globals from the main function.
Expand Down
Loading
Loading