Skip to content

Commit

Permalink
fix: Ensure that destination register is allocated when moving betwee…
Browse files Browse the repository at this point in the history
…n 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.
  • Loading branch information
sirasistant authored Feb 9, 2024
1 parent d1a2d18 commit ca0a56e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion compiler/noirc_evaluator/src/brillig/brillig_ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,11 @@ impl BrilligContext {
//
// This means that the arguments will be in the first `n` registers after
// the number of reserved registers.
let (sources, destinations) =
let (sources, destinations): (Vec<_>, Vec<_>) =
arguments.iter().enumerate().map(|(i, argument)| (*argument, self.register(i))).unzip();
destinations
.iter()
.for_each(|destination| self.registers.ensure_register_is_allocated(*destination));
self.mov_registers_to_registers_instruction(sources, destinations);
saved_registers
}
Expand Down
3 changes: 1 addition & 2 deletions tooling/debugger/ignored-tests.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,4 @@ scalar_mul
signed_comparison
simple_2d_array
to_bytes_integration
bigint
brillig_slices
bigint

0 comments on commit ca0a56e

Please sign in to comment.