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: Ignore no_predicates in brillig functions #5012

Merged
merged 2 commits into from
May 10, 2024
Merged
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: 4 additions & 3 deletions compiler/noirc_evaluator/src/ssa/opt/inlining.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::ssa::{
ir::{
basic_block::BasicBlockId,
dfg::{CallStack, InsertInstructionResult},
function::{Function, FunctionId},
function::{Function, FunctionId, RuntimeType},
instruction::{Instruction, InstructionId, TerminatorInstruction},
value::{Value, ValueId},
},
Expand Down Expand Up @@ -392,10 +392,11 @@ impl<'function> PerFunctionContext<'function> {
Some(func_id) => {
let function = &ssa.functions[&func_id];
// If we have not already finished the flattening pass, functions marked
// to not have predicates should be marked as entry points.
// to not have predicates should be marked as entry points unless we are inlining into brillig.
let no_predicates_is_entry_point =
self.context.no_predicates_is_entry_point
&& function.is_no_predicates();
&& function.is_no_predicates()
&& !matches!(self.source_function.runtime(), RuntimeType::Brillig);
if function.runtime().is_entry_point() || no_predicates_is_entry_point {
self.push_instruction(*id);
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[package]
name = "no_predicates_brillig"
type = "bin"
authors = [""]
compiler_version = ">=0.27.0"

[dependencies]
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = "10"
y = "20"
12 changes: 12 additions & 0 deletions test_programs/execution_success/no_predicates_brillig/src/main.nr
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
unconstrained fn main(x: u32, y: pub u32) {
basic_checks(x, y);
}

#[no_predicates]
fn basic_checks(x: u32, y: u32) {
if x > y {
assert(x == 10);
} else {
assert(y == 20);
}
}
Loading