Skip to content

Commit ca0a56e

Browse files
authored
fix: Ensure that destination register is allocated when moving between registers in brillig gen (#4316)
# Description ## Problem\* Resolves AztecProtocol/aztec-packages#4513 ## Summary\* Move registers to registers wasn't ensuring that the destinations were allocated so it was possible to codegen a case where move registers to registers was squashing values ## Additional Context ## Documentation\* Check one: - [x] No documentation needed. - [ ] Documentation included in this PR. - [ ] **[Exceptional Case]** Documentation to be submitted in a separate PR. # PR Checklist\* - [x] I have tested the changes locally. - [x] I have formatted the changes with [Prettier](https://prettier.io/) and/or `cargo fmt` on default settings.
1 parent d1a2d18 commit ca0a56e

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

compiler/noirc_evaluator/src/brillig/brillig_ir.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,11 @@ impl BrilligContext {
916916
//
917917
// This means that the arguments will be in the first `n` registers after
918918
// the number of reserved registers.
919-
let (sources, destinations) =
919+
let (sources, destinations): (Vec<_>, Vec<_>) =
920920
arguments.iter().enumerate().map(|(i, argument)| (*argument, self.register(i))).unzip();
921+
destinations
922+
.iter()
923+
.for_each(|destination| self.registers.ensure_register_is_allocated(*destination));
921924
self.mov_registers_to_registers_instruction(sources, destinations);
922925
saved_registers
923926
}

tooling/debugger/ignored-tests.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,4 @@ scalar_mul
1616
signed_comparison
1717
simple_2d_array
1818
to_bytes_integration
19-
bigint
20-
brillig_slices
19+
bigint

0 commit comments

Comments
 (0)