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

feat: Sync from noir #10307

Merged
merged 43 commits into from
Dec 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
369ea54
[1 changes] feat: Sync from aztec-packages (https://github.com/noir-l…
AztecBot Nov 29, 2024
8de9057
chore: apply sync fixes
AztecBot Nov 29, 2024
d1cbba5
[1 changes] feat(ssa): Option to set the maximum acceptable Brillig b…
AztecBot Nov 30, 2024
3311744
chore: apply sync fixes
AztecBot Nov 30, 2024
f2cef7c
feat(ssa): Option to set the maximum acceptable Brillig bytecode incr…
AztecBot Nov 30, 2024
ed5ec28
[1 changes] feat(ssa): Option to set the maximum acceptable Brillig b…
AztecBot Dec 1, 2024
2ab9ea9
chore: apply sync fixes
AztecBot Dec 1, 2024
268bd31
feat(ssa): Option to set the maximum acceptable Brillig bytecode incr…
AztecBot Dec 1, 2024
d36e23a
[1 changes] feat(ssa): Option to set the maximum acceptable Brillig b…
AztecBot Dec 2, 2024
d77d424
chore: apply sync fixes
AztecBot Dec 2, 2024
c1781ec
feat(ssa): Option to set the maximum acceptable Brillig bytecode incr…
AztecBot Dec 2, 2024
f8acd2e
[1 changes] feat: Reduce memory consumption by storing array length a…
AztecBot Dec 2, 2024
ea74bcd
chore: apply sync fixes
AztecBot Dec 2, 2024
c0f1030
feat: Reduce memory consumption by storing array length as `u32` duri…
AztecBot Dec 2, 2024
30daa73
Merge branch 'master' into sync-noir
TomAFrench Dec 2, 2024
4b35f0a
[1 changes] feat(ssa): Simplify array get from set that writes to the…
AztecBot Dec 3, 2024
6bc6f32
chore: apply sync fixes
AztecBot Dec 3, 2024
a92b956
feat(ssa): Simplify array get from set that writes to the same dynami…
AztecBot Dec 3, 2024
bf993f3
[1 changes] chore: fix warning when compiling `noir_wasm` (https://gi…
AztecBot Dec 3, 2024
70201f7
chore: apply sync fixes
AztecBot Dec 3, 2024
01a88de
chore: fix warning when compiling `noir_wasm` (https://github.com/noi…
AztecBot Dec 3, 2024
c2cb837
[1 changes] fix: Don't remove necessary RC instructions in DIE pass (…
AztecBot Dec 3, 2024
61716dc
chore: apply sync fixes
AztecBot Dec 3, 2024
bcded2c
fix: Don't remove necessary RC instructions in DIE pass (https://gith…
AztecBot Dec 3, 2024
4772967
Merge branch 'master' into sync-noir
TomAFrench Dec 3, 2024
3ffcc94
[1 changes] chore: Revert "fix: Don't remove necessary RC instruction…
AztecBot Dec 4, 2024
94da40c
chore: apply sync fixes
AztecBot Dec 4, 2024
feef655
chore: Revert "fix: Don't remove necessary RC instructions in DIE pas…
AztecBot Dec 4, 2024
70cf870
[1 changes] feat: revert changes to `ValueMerger` and `Instruction::I…
AztecBot Dec 4, 2024
47e3e69
chore: apply sync fixes
AztecBot Dec 4, 2024
f4c94c7
feat: revert changes to `ValueMerger` and `Instruction::IfElse` (http…
AztecBot Dec 4, 2024
b6c7773
[1 changes] chore: update release-please action (https://github.com/n…
AztecBot Dec 5, 2024
7c377b2
chore: apply sync fixes
AztecBot Dec 5, 2024
df46b8f
chore: update release-please action (https://github.com/noir-lang/noi…
AztecBot Dec 5, 2024
e276378
Merge branch 'master' into sync-noir
TomAFrench Dec 5, 2024
905851e
Update noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/die.rs
TomAFrench Dec 5, 2024
b4135ed
[1 changes] chore: Remove inliner override for `reference_counts` tes…
AztecBot Dec 5, 2024
40c2a72
chore: apply sync fixes
AztecBot Dec 5, 2024
c61e6a3
chore: Remove inliner override for `reference_counts` test (https://g…
AztecBot Dec 5, 2024
e11cb11
Merge branch 'master' into sync-noir
vezenovm Dec 5, 2024
063afbc
Update noir/noir-repo/compiler/noirc_evaluator/src/ssa/opt/constant_f…
vezenovm Dec 5, 2024
bbf5a1d
remove duplicated tests
vezenovm Dec 5, 2024
bcfb2f6
correct reference_counts test
vezenovm Dec 5, 2024
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
Prev Previous commit
Next Next commit
[1 changes] feat(ssa): Option to set the maximum acceptable Brillig b…
…ytecode increase in unrolling (noir-lang/noir#6641)

feat: Sync from aztec-packages (noir-lang/noir#6656)
chore: refactor poseidon2 (noir-lang/noir#6655)
fix: correct types returned by constant EC operations simplified within SSA (noir-lang/noir#6652)
feat: Sync from aztec-packages (noir-lang/noir#6634)
fix: used signed division for signed modulo (noir-lang/noir#6635)
fix(ssa): don't deduplicate constraints in blocks that are not dominated (noir-lang/noir#6627)
chore: pin foundry version in CI (noir-lang/noir#6642)
feat(ssa): Deduplicate intrinsics with predicates (noir-lang/noir#6615)
chore: improve error message of `&T` (noir-lang/noir#6633)
fix: LSP code action wasn't triggering on beginning or end of identifier (noir-lang/noir#6616)
chore!: remove `ec` module from stdlib (noir-lang/noir#6612)
fix(LSP): use generic self type to narrow down methods to complete (noir-lang/noir#6617)
fix!: Disallow `#[export]` on associated methods (noir-lang/noir#6626)
chore: redo typo PR by donatik27 (noir-lang/noir#6575)
chore: redo typo PR by Dimitrolito (noir-lang/noir#6614)
feat: simplify `jmpif`s by reversing branches if condition is negated (noir-lang/noir#5891)
fix: Do not warn on unused functions marked with #[export] (noir-lang/noir#6625)
chore: Add panic for compiler error described in #6620 (noir-lang/noir#6621)
feat(perf): Track last loads per block in mem2reg and remove them if possible (noir-lang/noir#6088)
fix(ssa): Track all local allocations during flattening (noir-lang/noir#6619)
feat(comptime): Implement blackbox functions in comptime interpreter (noir-lang/noir#6551)
chore: derive PartialEq and Hash for FieldElement (noir-lang/noir#6610)
chore: ignore almost-empty directories in nargo_cli tests (noir-lang/noir#6611)
chore: remove temporary allocations from `num_bits` (noir-lang/noir#6600)
chore: Release Noir(1.0.0-beta.0) (noir-lang/noir#6562)
feat: Add `array_refcount` and `slice_refcount` builtins for debugging (noir-lang/noir#6584)
chore!: Require types of globals to be specified (noir-lang/noir#6592)
fix: don't report visibility errors when elaborating comptime value (noir-lang/noir#6498)
fix: preserve newlines between comments when formatting statements (noir-lang/noir#6601)
fix: parse a bit more SSA stuff (noir-lang/noir#6599)
chore!: remove eddsa from stdlib (noir-lang/noir#6591)
chore: Typo in oracles how to (noir-lang/noir#6598)
feat(ssa): Loop invariant code motion (noir-lang/noir#6563)
fix: remove `compiler_version` from new `Nargo.toml` (noir-lang/noir#6590)
feat: Avoid incrementing reference counts in some cases (noir-lang/noir#6568)
chore: fix typo in test name (noir-lang/noir#6589)
fix: consider prereleases to be compatible with pre-1.0.0 releases (noir-lang/noir#6580)
feat: try to inline brillig calls with all constant arguments  (noir-lang/noir#6548)
fix: correct type when simplifying `derive_pedersen_generators` (noir-lang/noir#6579)
feat: Sync from aztec-packages (noir-lang/noir#6576)
AztecBot committed Dec 2, 2024
commit d36e23abcf1b7a4cf8c5f3f6a2afdbb2f620c1ab
2 changes: 1 addition & 1 deletion .noir-sync-commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
68c32b4ffd9b069fe4b119327dbf4018c17ab9d4
4ff308128755c95b4d461bbcb7e3a49f16145585
1 change: 1 addition & 0 deletions noir/noir-repo/Cargo.lock

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

2 changes: 1 addition & 1 deletion noir/noir-repo/acvm-repo/acvm_js/build.sh
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@ function run_if_available {
require_command jq
require_command cargo
require_command wasm-bindgen
#require_command wasm-opt
require_command wasm-opt

self_path=$(dirname "$(readlink -f "$0")")
pname=$(cargo read-manifest | jq -r '.name')
2 changes: 1 addition & 1 deletion noir/noir-repo/compiler/integration-tests/package.json
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
"lint": "NODE_NO_WARNINGS=1 eslint . --ext .ts --ignore-path ./.eslintignore --max-warnings 0"
},
"dependencies": {
"@aztec/bb.js": "portal:../../../../barretenberg/ts",
"@aztec/bb.js": "0.63.1",
"@noir-lang/noir_js": "workspace:*",
"@noir-lang/noir_wasm": "workspace:*",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.0",
11 changes: 10 additions & 1 deletion noir/noir-repo/compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
@@ -126,11 +126,19 @@ pub struct CompileOptions {
#[arg(long)]
pub skip_underconstrained_check: bool,

/// Setting to decide on an inlining strategy for brillig functions.
/// Setting to decide on an inlining strategy for Brillig functions.
/// A more aggressive inliner should generate larger programs but more optimized
/// A less aggressive inliner should generate smaller programs
#[arg(long, hide = true, allow_hyphen_values = true, default_value_t = i64::MAX)]
pub inliner_aggressiveness: i64,

/// Setting the maximum acceptable increase in Brillig bytecode size due to
/// unrolling small loops. When left empty, any change is accepted as long
/// as it required fewer SSA instructions.
/// A higher value results in fewer jumps but a larger program.
/// A lower value keeps the original program if it was smaller, even if it has more jumps.
#[arg(long, hide = true, allow_hyphen_values = true)]
pub max_bytecode_increase_percent: Option<i32>,
}

pub fn parse_expression_width(input: &str) -> Result<ExpressionWidth, std::io::Error> {
@@ -589,6 +597,7 @@ pub fn compile_no_check(
emit_ssa: if options.emit_ssa { Some(context.package_build_path.clone()) } else { None },
skip_underconstrained_check: options.skip_underconstrained_check,
inliner_aggressiveness: options.inliner_aggressiveness,
max_bytecode_increase_percent: options.max_bytecode_increase_percent,
};

let SsaProgramArtifact { program, debug, warnings, names, brillig_names, error_types, .. } =
1 change: 1 addition & 0 deletions noir/noir-repo/compiler/noirc_evaluator/Cargo.toml
Original file line number Diff line number Diff line change
@@ -33,6 +33,7 @@ cfg-if.workspace = true
proptest.workspace = true
similar-asserts.workspace = true
num-traits.workspace = true
test-case.workspace = true

[features]
bn254 = ["noirc_frontend/bn254"]
8 changes: 3 additions & 5 deletions noir/noir-repo/compiler/noirc_evaluator/src/brillig/mod.rs
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ use self::{
},
};
use crate::ssa::{
ir::function::{Function, FunctionId, RuntimeType},
ir::function::{Function, FunctionId},
ssa_gen::Ssa,
};
use fxhash::FxHashMap as HashMap;
@@ -59,17 +59,15 @@ impl std::ops::Index<FunctionId> for Brillig {
}

impl Ssa {
/// Compile to brillig brillig functions and ACIR functions reachable from them
/// Compile Brillig functions and ACIR functions reachable from them
#[tracing::instrument(level = "trace", skip_all)]
pub(crate) fn to_brillig(&self, enable_debug_trace: bool) -> Brillig {
// Collect all the function ids that are reachable from brillig
// That means all the functions marked as brillig and ACIR functions called by them
let brillig_reachable_function_ids = self
.functions
.iter()
.filter_map(|(id, func)| {
matches!(func.runtime(), RuntimeType::Brillig(_)).then_some(*id)
})
.filter_map(|(id, func)| func.runtime().is_brillig().then_some(*id))
.collect::<BTreeSet<_>>();

let mut brillig = Brillig::default();
19 changes: 13 additions & 6 deletions noir/noir-repo/compiler/noirc_evaluator/src/ssa.rs
Original file line number Diff line number Diff line change
@@ -67,6 +67,11 @@ pub struct SsaEvaluatorOptions {

/// The higher the value, the more inlined brillig functions will be.
pub inliner_aggressiveness: i64,

/// Maximum accepted percentage increase in the Brillig bytecode size after unrolling loops.
/// When `None` the size increase check is skipped altogether and any decrease in the SSA
/// instruction count is accepted.
pub max_bytecode_increase_percent: Option<i32>,
}

pub(crate) struct ArtifactsAndWarnings(Artifacts, Vec<SsaReport>);
@@ -104,7 +109,10 @@ pub(crate) fn optimize_into_acir(
"After `static_assert` and `assert_constant`:",
)?
.run_pass(Ssa::loop_invariant_code_motion, "After Loop Invariant Code Motion:")
.try_run_pass(Ssa::unroll_loops_iteratively, "After Unrolling:")?
.try_run_pass(
|ssa| ssa.unroll_loops_iteratively(options.max_bytecode_increase_percent),
"After Unrolling:",
)?
.run_pass(Ssa::simplify_cfg, "After Simplifying (2nd):")
.run_pass(Ssa::flatten_cfg, "After Flattening:")
.run_pass(Ssa::remove_bit_shifts, "After Removing Bit Shifts:")
@@ -450,11 +458,10 @@ impl SsaBuilder {
}

/// The same as `run_pass` but for passes that may fail
fn try_run_pass(
mut self,
pass: fn(Ssa) -> Result<Ssa, RuntimeError>,
msg: &str,
) -> Result<Self, RuntimeError> {
fn try_run_pass<F>(mut self, pass: F, msg: &str) -> Result<Self, RuntimeError>
where
F: FnOnce(Ssa) -> Result<Ssa, RuntimeError>,
{
self.ssa = time(msg, self.print_codegen_timings, || pass(self.ssa))?;
Ok(self.print(msg))
}
Original file line number Diff line number Diff line change
@@ -197,6 +197,12 @@ impl Function {
}
}

impl Clone for Function {
fn clone(&self) -> Self {
Function::clone_with_id(self.id(), self)
}
}

impl std::fmt::Display for RuntimeType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
15 changes: 13 additions & 2 deletions noir/noir-repo/compiler/noirc_evaluator/src/ssa/ir/instruction.rs
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@ use fxhash::FxHasher64;
use iter_extended::vecmap;
use noirc_frontend::hir_def::types::Type as HirType;

use crate::ssa::opt::flatten_cfg::value_merger::ValueMerger;
use crate::ssa::{ir::function::RuntimeType, opt::flatten_cfg::value_merger::ValueMerger};

use super::{
basic_block::BasicBlockId,
@@ -478,8 +478,19 @@ impl Instruction {
| ArraySet { .. }
| MakeArray { .. } => true,

// Store instructions must be removed by DIE in acir code, any load
// instructions should already be unused by that point.
//
// Note that this check assumes that it is being performed after the flattening
// pass and after the last mem2reg pass. This is currently the case for the DIE
// pass where this check is done, but does mean that we cannot perform mem2reg
// after the DIE pass.
Store { .. } => {
matches!(function.runtime(), RuntimeType::Acir(_))
&& function.reachable_blocks().len() == 1
}

Constrain(..)
| Store { .. }
| EnableSideEffectsIf { .. }
| IncrementRc { .. }
| DecrementRc { .. }
Loading