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

feat: Sync from aztec-packages #6656

Merged
merged 12 commits into from
Nov 29, 2024
2 changes: 1 addition & 1 deletion .aztec-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1bfc15e08873a1f0f3743e259f418b70426b3f25
0577c1a70e9746bd06f07d2813af1be39e01ca02
2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/ssa/opt/constant_folding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1495,4 +1495,4 @@ mod test {
let ssa = ssa.fold_constants_using_constraints();
assert_normalized_ssa_equals(ssa, expected);
}
}
}
2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/ssa/opt/flatten_cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1501,4 +1501,4 @@ mod test {
let merged_ssa = Ssa::from_str(src).unwrap();
let _ = merged_ssa.flatten_cfg();
}
}
}
2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
//!
//! Repeating this algorithm for each block in the function in program order should result in
//! optimizing out most known loads. However, identifying all aliases correctly has been proven
//! undecidable in general (Landi, 1992). So this pass will not always optimize out all loads

Check warning on line 69 in compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Landi)
//! that could theoretically be optimized out. This pass can be performed at any time in the
//! SSA optimization pipeline, although it will be more successful the simpler the program's CFG is.
//! This pass is currently performed several times to enable other passes - most notably being
Expand Down Expand Up @@ -127,7 +127,7 @@
/// Load and Store instructions that should be removed at the end of the pass.
///
/// We avoid removing individual instructions as we go since removing elements
/// from the middle of Vecs many times will be slower than a single call to `retain`.

Check warning on line 130 in compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (Vecs)
instructions_to_remove: HashSet<InstructionId>,

/// Track a value's last load across all blocks.
Expand Down Expand Up @@ -1225,4 +1225,4 @@
// We expect the program to be unchanged
assert_normalized_ssa_equals(ssa, src);
}
}
}
3 changes: 0 additions & 3 deletions compiler/noirc_evaluator/src/ssa/ssa_gen/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,9 +733,6 @@ impl<'a> FunctionContext<'a> {
let element_types = Self::convert_type(element_type);
values.map_both(element_types, |value, element_type| {
let reference = value.eval_reference();
// Reference counting in brillig relies on us incrementing reference
// counts when arrays/slices are constructed or indexed.
// Thus, if we dereference an lvalue which happens to be array/slice we should increment its reference counter.
self.builder.insert_load(reference, element_type).into()
})
}
Expand Down
25 changes: 21 additions & 4 deletions tooling/profiler/src/cli/gates_flamegraph_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ pub(crate) struct GatesFlamegraphCommand {
/// The output folder for the flamegraph svg files
#[clap(long, short)]
output: String,

/// The output name for the flamegraph svg files
#[clap(long, short = 'f')]
output_filename: Option<String>,
}

pub(crate) fn run(args: GatesFlamegraphCommand) -> eyre::Result<()> {
Expand All @@ -43,6 +47,7 @@ pub(crate) fn run(args: GatesFlamegraphCommand) -> eyre::Result<()> {
},
&InfernoFlamegraphGenerator { count_name: "gates".to_string() },
&PathBuf::from(args.output),
args.output_filename,
)
}

Expand All @@ -51,6 +56,7 @@ fn run_with_provider<Provider: GatesProvider, Generator: FlamegraphGenerator>(
gates_provider: &Provider,
flamegraph_generator: &Generator,
output_path: &Path,
output_filename: Option<String>,
) -> eyre::Result<()> {
let mut program =
read_program_from_file(artifact_path).context("Error reading program from file")?;
Expand Down Expand Up @@ -91,13 +97,18 @@ fn run_with_provider<Provider: GatesProvider, Generator: FlamegraphGenerator>(
})
.collect();

let output_filename = if let Some(output_filename) = &output_filename {
format!("{}::{}::gates.svg", output_filename, func_name)
} else {
format!("{}::gates.svg", func_name)
};
flamegraph_generator.generate_flamegraph(
samples,
&debug_artifact.debug_symbols[func_idx],
&debug_artifact,
artifact_path.to_str().unwrap(),
&func_name,
&Path::new(&output_path).join(Path::new(&format!("{}_gates.svg", &func_name))),
&Path::new(&output_path).join(Path::new(&output_filename)),
)?;
}

Expand Down Expand Up @@ -189,11 +200,17 @@ mod tests {
};
let flamegraph_generator = TestFlamegraphGenerator::default();

super::run_with_provider(&artifact_path, &provider, &flamegraph_generator, temp_dir.path())
.expect("should run without errors");
super::run_with_provider(
&artifact_path,
&provider,
&flamegraph_generator,
temp_dir.path(),
Some(String::from("test_filename")),
)
.expect("should run without errors");

// Check that the output file was written to
let output_file = temp_dir.path().join("main_gates.svg");
let output_file = temp_dir.path().join("test_filename::main::gates.svg");
assert!(output_file.exists());
}
}
Loading