Skip to content
Closed
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
7 changes: 2 additions & 5 deletions compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,8 @@ impl<'f> PerFunctionContext<'f> {
/// This is expected to contain any loads which were replaced and any stores which are
/// no longer needed.
fn remove_instructions(&mut self) {
// The order we iterate blocks in is not important
for block in self.post_order.as_slice() {
self.inserter.function.dfg[*block]
.instructions_mut()
.retain(|instruction| !self.instructions_to_remove.contains(instruction));
for instruction in &self.instructions_to_remove {
self.inserter.function.dfg.remove_instruction(*instruction);
}
}

Expand Down
14 changes: 3 additions & 11 deletions compiler/noirc_evaluator/src/ssa/opt/rc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ impl Function {
context.find_rcs_in_entry_block(self);
context.scan_for_array_sets(self);
let to_remove = context.find_rcs_to_remove(self);
remove_instructions(to_remove, self);
for instruction in to_remove {
self.dfg.remove_instruction(instruction);
}
}
}

Expand Down Expand Up @@ -141,16 +143,6 @@ pub(crate) fn pop_rc_for(
Some(rcs.remove(position))
}

fn remove_instructions(to_remove: HashSet<InstructionId>, function: &mut Function) {
if !to_remove.is_empty() {
for block in function.reachable_blocks() {
function.dfg[block]
.instructions_mut()
.retain(|instruction| !to_remove.contains(instruction));
}
}
}

#[cfg(test)]
mod test {
use std::sync::Arc;
Expand Down