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: Fix issue with unresolved results #5453

Merged
merged 2 commits into from
Jul 9, 2024
Merged
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
impl Ssa {
/// Go through each top-level non-brillig function and detect if it has independent subgraphs
#[tracing::instrument(level = "trace", skip(self))]
pub(crate) fn check_for_underconstrained_values(&mut self) -> Vec<SsaReport> {

Check warning on line 18 in compiler/noirc_evaluator/src/ssa/checks/check_for_underconstrained_values.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (underconstrained)
let mut warnings: Vec<SsaReport> = Vec::new();
for function in self.functions.values() {
match function.runtime() {
RuntimeType::Acir { .. } => {
warnings.extend(check_for_underconstrained_values_within_function(

Check warning on line 23 in compiler/noirc_evaluator/src/ssa/checks/check_for_underconstrained_values.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (underconstrained)
function,
&self.functions,
));
Expand All @@ -33,7 +33,7 @@
}

/// Detect independent subgraphs (not connected to function inputs or outputs) and return a vector of bug reports if some are found
fn check_for_underconstrained_values_within_function(

Check warning on line 36 in compiler/noirc_evaluator/src/ssa/checks/check_for_underconstrained_values.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (underconstrained)
function: &Function,
all_functions: &BTreeMap<FunctionId, Function>,
) -> Vec<SsaReport> {
Expand Down Expand Up @@ -105,7 +105,15 @@
.iter()
.chain(function.returns())
.filter(|id| function.dfg.get_numeric_constant(**id).is_none())
.copied();
.copied()
TomAFrench marked this conversation as resolved.
Show resolved Hide resolved
.chain(
function
.parameters()
.iter()
.chain(function.returns())
.filter(|id| function.dfg.get_numeric_constant(**id).is_none())
.map(|value_id| function.dfg.resolve(*value_id)),
);

let mut connected_sets_indices: HashSet<usize> = HashSet::new();

Expand Down Expand Up @@ -170,12 +178,14 @@
function.dfg[*instruction].for_each_value(|value_id| {
if function.dfg.get_numeric_constant(value_id).is_none() {
instruction_arguments_and_results.insert(value_id);
instruction_arguments_and_results.insert(function.dfg.resolve(value_id));
}
});
// And non-constant results
for value_id in function.dfg.instruction_results(*instruction).iter() {
if function.dfg.get_numeric_constant(*value_id).is_none() {
instruction_arguments_and_results.insert(*value_id);
instruction_arguments_and_results.insert(function.dfg.resolve(*value_id));
}
}

Expand Down Expand Up @@ -360,7 +370,7 @@
builder.terminate_with_return(vec![v2]);

let mut ssa = builder.finish();
let ssa_level_warnings = ssa.check_for_underconstrained_values();

Check warning on line 373 in compiler/noirc_evaluator/src/ssa/checks/check_for_underconstrained_values.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (underconstrained)
assert_eq!(ssa_level_warnings.len(), 0);
}

Expand Down Expand Up @@ -405,7 +415,7 @@
let v2 = builder.insert_binary(v0, BinaryOp::Add, v1);
builder.terminate_with_return(vec![v2]);
let mut ssa = builder.finish();
let ssa_level_warnings = ssa.check_for_underconstrained_values();

Check warning on line 418 in compiler/noirc_evaluator/src/ssa/checks/check_for_underconstrained_values.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (underconstrained)
assert_eq!(ssa_level_warnings.len(), 1);
}
}
Loading