Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
11 changes: 11 additions & 0 deletions compiler/noirc_evaluator/src/ssa/opt/mem2reg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,9 @@ struct PerFunctionContext<'f> {
/// Track whether a reference was passed into another entry point
/// This is needed to determine whether we can remove a store.
calls_reference_input: HashSet<ValueId>,
/// Track whether a reference was passed into a make array instruction
/// This is needed to determine whether we can remove a store.
make_array_references: HashSet<ValueId>,
Comment thread
jfecher marked this conversation as resolved.
Outdated

/// Track whether a reference has been aliased, and store the respective
/// instruction that aliased that reference.
Expand All @@ -161,6 +164,7 @@ impl<'f> PerFunctionContext<'f> {
last_loads: HashMap::default(),
calls_reference_input: HashSet::default(),
aliased_references: HashMap::default(),
make_array_references: HashSet::default(),
}
}

Expand Down Expand Up @@ -245,6 +249,12 @@ impl<'f> PerFunctionContext<'f> {
return true;
}

let allocation_aliases_parameter =
aliases.any(|alias| self.make_array_references.contains(&alias));
if allocation_aliases_parameter == Some(true) {
Comment thread
vezenovm marked this conversation as resolved.
Outdated
return true;
}

let allocation_aliases_parameter =
aliases.any(|alias| all_terminator_values.contains(&alias));
if allocation_aliases_parameter == Some(true) {
Expand Down Expand Up @@ -551,6 +561,7 @@ impl<'f> PerFunctionContext<'f> {

for element in elements {
aliases.insert(*element);
self.make_array_references.insert(*element);
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions test_programs/execution_success/regression_8739/Nargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "regression_8739"
type = "bin"
authors = [""]

[dependencies]
15 changes: 15 additions & 0 deletions test_programs/execution_success/regression_8739/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
fn main() {
// Safety: testing context
unsafe {
func_2()
}
}
unconstrained fn func_2() {
let mut a: [&mut bool; 1] = [(&mut true)];
let mut idx_b: u32 = 0;
while (*a[0]) {
if (idx_b == 0) {
Comment thread
vezenovm marked this conversation as resolved.
Outdated
break;
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.