Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jfecher committed Nov 7, 2024
1 parent 1f22e0b commit 6954811
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ impl<'f> PerFunctionContext<'f> {
fn analyze_block(&mut self, block: BasicBlockId, mut references: Block) {
let instructions = self.inserter.function.dfg[block].take_instructions();

// If this is the entry block, take all the block parameters and assume they may
// be aliased to each other
if block == self.inserter.function.entry_block() {
self.add_aliases_for_reference_parameters(block, &mut references);
}
Expand All @@ -326,9 +328,10 @@ impl<'f> PerFunctionContext<'f> {
self.blocks.insert(block, references);
}

/// Add a self-alias for input parameters, similarly to how a newly allocated reference has
/// one alias already - itself. If we don't, then the checks using `reference_parameters()`
/// might find the default (empty) aliases and think the an input reference can be removed.
/// Go through each parameter and register that all reference parameters of the same type are
/// possibly aliased to each other. If there are parameters with nested references (arrays of
/// references or references containing other references) we give up and assume all parameter
/// references are `AliasSet::unknown()`.
fn add_aliases_for_reference_parameters(&self, block: BasicBlockId, references: &mut Block) {
let dfg = &self.inserter.function.dfg;
let params = dfg.block_parameters(block);
Expand Down

0 comments on commit 6954811

Please sign in to comment.