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
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ build-data = "^0.3.3"
bincode = { version = "^2.0.1", features = ["serde"] }
hex = "0.4.2"
const_format = "0.2.30"
indexmap = "^2.10.0"
lazy_static = "1.4"
libfuzzer-sys = "0.4"
num-bigint = "0.4"
Expand Down
5 changes: 2 additions & 3 deletions acvm-repo/acvm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ fxhash.workspace = true
acir.workspace = true
brillig_vm.workspace = true
acvm_blackbox_solver.workspace = true

indexmap = "^2.10.0"
indexmap.workspace = true

[features]
bn254 = ["acir/bn254", "brillig_vm/bn254", "acvm_blackbox_solver/bn254"]
Expand All @@ -46,7 +45,7 @@ zkhash = { version = "^0.2.0", default-features = false }
ark-bn254-v04 = { package = "ark-bn254", version = "^0.4.0", default-features = false, features = [
"curve",
] }
ark-ff-v04 = { package = "ark-ff", version = "^0.4.0", default-features = false }
ark-ff-v04 = { package = "ark-ff", version = "^0.4.0", default-features = false }
criterion.workspace = true
pprof.workspace = true

Expand Down
1 change: 1 addition & 0 deletions compiler/noirc_evaluator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ num-bigint.workspace = true
num-integer.workspace = true
num-traits.workspace = true
im.workspace = true
indexmap.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_with = "3.2.0"
Expand Down
6 changes: 3 additions & 3 deletions compiler/noirc_evaluator/src/ssa/ir/dfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl DataFlowGraph {
block: BasicBlockId,
ctrl_typevars: Option<Vec<Type>>,
call_stack: CallStackId,
) -> InsertInstructionResult {
) -> InsertInstructionResult<'_> {
if !self.is_handled_by_runtime(&instruction) {
// Panicking to raise attention. If we're not supposed to simplify it immediately,
// pushing the instruction would just cause a potential panic later on.
Expand All @@ -274,7 +274,7 @@ impl DataFlowGraph {
block: BasicBlockId,
ctrl_typevars: Option<Vec<Type>>,
call_stack: CallStackId,
) -> InsertInstructionResult {
) -> InsertInstructionResult<'_> {
self.insert_instruction_and_results_if_simplified(
instruction,
block,
Expand All @@ -292,7 +292,7 @@ impl DataFlowGraph {
ctrl_typevars: Option<Vec<Type>>,
call_stack: CallStackId,
existing_id: Option<InstructionId>,
) -> InsertInstructionResult {
) -> InsertInstructionResult<'_> {
if !self.is_handled_by_runtime(&instruction) {
// BUG: With panicking it fails to build the `token_contract`; see:
// https://github.com/AztecProtocol/aztec-packages/pull/11294#issuecomment-2624379102
Expand Down
12 changes: 7 additions & 5 deletions compiler/noirc_evaluator/src/ssa/ir/function_inserter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ impl<'f> FunctionInserter<'f> {
self.function.dfg.data_bus = data_bus;
}

/// Push a new instruction to the given block and return its new InstructionId.
/// If the instruction was simplified out of the program, None is returned.
/// Push a new instruction to the given block and return its new `InstructionId`.
/// If the instruction was simplified out of the program, `None` is returned.
pub(crate) fn push_instruction(
&mut self,
id: InstructionId,
Expand All @@ -105,7 +105,7 @@ impl<'f> FunctionInserter<'f> {
id: InstructionId,
block: BasicBlockId,
call_stack: CallStackId,
) -> InsertInstructionResult {
) -> InsertInstructionResult<'_> {
let results = self.function.dfg.instruction_results(id).to_vec();

let ctrl_typevars = instruction
Expand Down Expand Up @@ -136,9 +136,11 @@ impl<'f> FunctionInserter<'f> {
}
}

/// Associates each block parameter with a value, unless the parameter already has a value,
/// in which case it is kept as-is.
pub(crate) fn remember_block_params(&mut self, block: BasicBlockId, new_values: &[ValueId]) {
let old_parameters = self.function.dfg.block_parameters(block);

assert_eq!(old_parameters.len(), new_values.len());
for (param, new_param) in old_parameters.iter().zip(new_values) {
self.values.entry(*param).or_insert(*new_param);
}
Expand All @@ -151,7 +153,7 @@ impl<'f> FunctionInserter<'f> {
) {
let old_parameters = self.function.dfg.block_parameters(block);
let new_parameters = self.function.dfg.block_parameters(new_block);

assert_eq!(old_parameters.len(), new_parameters.len(),);
for (param, new_param) in old_parameters.iter().zip(new_parameters) {
// Don't overwrite any existing entries to avoid overwriting the induction variable
self.values.entry(*param).or_insert(*new_param);
Expand Down
2 changes: 1 addition & 1 deletion compiler/noirc_evaluator/src/ssa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ pub struct SsaEvaluatorOptions {
pub struct ArtifactsAndWarnings(pub Artifacts, pub Vec<SsaReport>);

/// The default SSA optimization pipeline.
pub fn primary_passes(options: &SsaEvaluatorOptions) -> Vec<SsaPass> {
pub fn primary_passes(options: &SsaEvaluatorOptions) -> Vec<SsaPass<'_>> {
vec![
SsaPass::new(Ssa::expand_signed_checks, "expand signed checks"),
SsaPass::new(Ssa::remove_unreachable_functions, "Removing Unreachable Functions"),
Expand Down
23 changes: 10 additions & 13 deletions compiler/noirc_evaluator/src/ssa/opt/basic_conditional.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::ssa::{
post_order::PostOrder,
value::ValueId,
},
opt::flatten_cfg::WorkList,
};

use super::flatten_cfg::Context;
Expand Down Expand Up @@ -304,31 +305,27 @@ impl Context<'_> {
//0. initialize the context for flattening a 'single conditional'
let old_target = self.target_block;
let old_no_predicate = self.no_predicate;
let mut queue = vec![];
self.target_block = conditional.block_entry;
self.no_predicate = true;
//1. process 'then' branch
self.inline_block(conditional.block_entry, no_predicates);
let to_process = self.handle_terminator(conditional.block_entry, &queue);
queue.extend(to_process);
let mut work_list = WorkList::new();
let to_process = self.handle_terminator(conditional.block_entry, &work_list);
work_list.extend(to_process);

if let Some(then) = conditional.block_then {
assert_eq!(queue.pop(), conditional.block_then);
assert_eq!(work_list.pop(), conditional.block_then);
self.inline_block(then, no_predicates);
let to_process = self.handle_terminator(then, &queue);

for incoming_block in to_process {
if !queue.contains(&incoming_block) {
queue.push(incoming_block);
}
}
let to_process = self.handle_terminator(then, &work_list);
work_list.extend(to_process);
}

//2. process 'else' branch, in case there is no 'then'
let next = queue.pop();
let next = work_list.pop();
if next == conditional.block_else {
let next = next.unwrap();
self.inline_block(next, no_predicates);
let _ = self.handle_terminator(next, &queue);
let _ = self.handle_terminator(next, &work_list);
} else {
assert_eq!(next, Some(conditional.block_exit));
}
Expand Down
Loading
Loading