Skip to content

Commit

Permalink
Use new collect_all_aliases function from master merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher committed Sep 5, 2023
1 parent dddb9c8 commit b2b10fc
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions crates/noirc_evaluator/src/ssa/opt/mem2reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ impl<'f> PerFunctionContext<'f> {
}
Instruction::MakeArray { elements, typ: _ } => {
let array = self.inserter.function.dfg.instruction_results(instruction)[0];
self.check_array_aliasing(references, array, elements);
self.handle_make_array(references, array, elements);
}
Instruction::ArrayGet { array, .. } => {
let result = self.inserter.function.dfg.instruction_results(instruction)[0];
Expand Down Expand Up @@ -313,7 +313,7 @@ impl<'f> PerFunctionContext<'f> {
}
}

fn check_array_aliasing(
fn handle_make_array(
&self,
references: &mut Block,
array: ValueId,
Expand All @@ -325,14 +325,11 @@ impl<'f> PerFunctionContext<'f> {
});

if contains_references {
// TODO: Check if type directly holds references or holds arrays that hold references
let expr = Expression::ArrayElement(Box::new(Expression::Other(array)));
references.expressions.insert(array, expr.clone());
let aliases = references.aliases.entry(expr).or_default();

for element in elements {
aliases.insert(*element);
}
let aliases = references.collect_all_aliases(elements);
references.aliases.insert(expr, aliases);
}
}

Expand Down

0 comments on commit b2b10fc

Please sign in to comment.