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

fix: discard ref counts during unrolling #4923

Merged
merged 12 commits into from
Apr 26, 2024
13 changes: 10 additions & 3 deletions compiler/noirc_evaluator/src/ssa/opt/unrolling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
//!
//! Note that this pass also often creates superfluous jmp instructions in the
//! program that will need to be removed by a later simplify cfg pass.
//! Note also that unrolling is skipped for Brillig runtime and as a result
//! we remove reference count instructions because they are only used by Brillig bytecode
use std::collections::HashSet;

use crate::{
Expand All @@ -24,7 +26,7 @@ use crate::{
dom::DominatorTree,
function::{Function, RuntimeType},
function_inserter::FunctionInserter,
instruction::TerminatorInstruction,
instruction::{Instruction, TerminatorInstruction},
post_order::PostOrder,
value::ValueId,
},
Expand Down Expand Up @@ -465,9 +467,14 @@ impl<'f> LoopIteration<'f> {
// instances of the induction variable or any values that were changed as a result
// of the new induction variable value.
for instruction in instructions {
self.inserter.push_instruction(instruction, self.insert_block);
// Skip reference count instructions since they are only used for brillig, and brillig code is not unrolled
if !matches!(
jfecher marked this conversation as resolved.
Show resolved Hide resolved
self.dfg()[instruction],
Instruction::IncrementRc { .. } | Instruction::DecrementRc { .. }
) {
self.inserter.push_instruction(instruction, self.insert_block);
}
}

let mut terminator = self.dfg()[self.source_block]
.unwrap_terminator()
.clone()
Expand Down
6 changes: 6 additions & 0 deletions test_programs/execution_success/regression_4709/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "regression_4709"
type = "bin"
authors = [""]

[dependencies]
2 changes: 2 additions & 0 deletions test_programs/execution_success/regression_4709/Prover.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = 1
y = 2
Loading
Loading