Skip to content

Commit

Permalink
fix: do not remove memory blocks used as brillig input (#7073)
Browse files Browse the repository at this point in the history
  • Loading branch information
guipublic authored Jan 15, 2025
1 parent 9471e28 commit 8d2a2dd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion acvm-repo/acvm/src/compiler/optimizers/unused_memory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use acir::circuit::{opcodes::BlockId, Circuit, Opcode};
use acir::circuit::{brillig::BrilligInputs, opcodes::BlockId, Circuit, Opcode};
use std::collections::HashSet;

/// `UnusedMemoryOptimizer` will remove initializations of memory blocks which are unused.
Expand Down Expand Up @@ -29,6 +29,13 @@ impl<F> UnusedMemoryOptimizer<F> {
Opcode::MemoryOp { block_id, .. } => {
unused_memory_initialization.remove(block_id);
}
Opcode::BrilligCall { inputs, .. } => {
for input in inputs {
if let BrilligInputs::MemoryArray(block) = input {
unused_memory_initialization.remove(block);
}
}
}
_ => (),
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "regression_7062"
type = "bin"
authors = [""]
compiler_version = ">=0.31.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main(args: [Field; 2]) {
/// Safety: n/a
unsafe { store(args) };
// Dummy test to remove the 'underconstraint bug'
assert(args[0] + args[1] != 0);
}

pub unconstrained fn store(_: [Field]) {}

0 comments on commit 8d2a2dd

Please sign in to comment.