From 7c42c620bddc6b95fba31e6641b694e19cf19609 Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Wed, 14 Aug 2024 19:09:55 +0000 Subject: [PATCH 1/2] enable the ability to toggle off the underconstrained check --- compiler/noirc_driver/src/lib.rs | 7 +++++++ compiler/noirc_evaluator/src/ssa.rs | 9 ++++++++- cspell.json | 1 + 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index 72c95823553..f3383ada490 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -123,6 +123,12 @@ pub struct CompileOptions { /// Temporary flag to enable the experimental arithmetic generics feature #[arg(long, hide = true)] pub arithmetic_generics: bool, + + /// Flag to turn off the compiler check for under constrained values. + /// Warning: This can improve compilation speed but can also lead to correctness errors. + /// This check should always be run on production code. + #[arg(long)] + pub skip_underconstrained_check: bool, } pub fn parse_expression_width(input: &str) -> Result { @@ -576,6 +582,7 @@ pub fn compile_no_check( ExpressionWidth::default() }, emit_ssa: if options.emit_ssa { Some(context.package_build_path.clone()) } else { None }, + skip_underconstrained_check: options.skip_underconstrained_check, }; let SsaProgramArtifact { program, debug, warnings, names, error_types, .. } = diff --git a/compiler/noirc_evaluator/src/ssa.rs b/compiler/noirc_evaluator/src/ssa.rs index b632958f37f..b43194cc2ac 100644 --- a/compiler/noirc_evaluator/src/ssa.rs +++ b/compiler/noirc_evaluator/src/ssa.rs @@ -64,6 +64,9 @@ pub struct SsaEvaluatorOptions { /// Dump the unoptimized SSA to the supplied path if it exists pub emit_ssa: Option, + + /// Skip the check for under constrained values + pub skip_underconstrained_check: bool, } pub(crate) struct ArtifactsAndWarnings(Artifacts, Vec); @@ -117,7 +120,11 @@ pub(crate) fn optimize_into_acir( .run_pass(Ssa::array_set_optimization, "After Array Set Optimizations:") .finish(); - let ssa_level_warnings = ssa.check_for_underconstrained_values(); + let ssa_level_warnings = if options.skip_underconstrained_check { + vec![] + } else { + time("After Check for Underconstrained Values", options.print_codegen_timings, || ssa.check_for_underconstrained_values()) + }; let brillig = time("SSA to Brillig", options.print_codegen_timings, || { ssa.to_brillig(options.enable_brillig_logging) }); diff --git a/cspell.json b/cspell.json index e939cd583e8..7b6ae369670 100644 --- a/cspell.json +++ b/cspell.json @@ -204,6 +204,7 @@ "typevar", "typevars", "udiv", + "underconstrained", "uninstantiated", "unnormalized", "unoptimized", From 1951d0451ba20e6895a2f9f111fde35e485ba88e Mon Sep 17 00:00:00 2001 From: Maxim Vezenov Date: Wed, 14 Aug 2024 19:10:07 +0000 Subject: [PATCH 2/2] Cargo fmt --- compiler/noirc_driver/src/lib.rs | 2 +- compiler/noirc_evaluator/src/ssa.rs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/compiler/noirc_driver/src/lib.rs b/compiler/noirc_driver/src/lib.rs index f3383ada490..c90304b053b 100644 --- a/compiler/noirc_driver/src/lib.rs +++ b/compiler/noirc_driver/src/lib.rs @@ -126,7 +126,7 @@ pub struct CompileOptions { /// Flag to turn off the compiler check for under constrained values. /// Warning: This can improve compilation speed but can also lead to correctness errors. - /// This check should always be run on production code. + /// This check should always be run on production code. #[arg(long)] pub skip_underconstrained_check: bool, } diff --git a/compiler/noirc_evaluator/src/ssa.rs b/compiler/noirc_evaluator/src/ssa.rs index b43194cc2ac..2925feb1bbe 100644 --- a/compiler/noirc_evaluator/src/ssa.rs +++ b/compiler/noirc_evaluator/src/ssa.rs @@ -123,7 +123,9 @@ pub(crate) fn optimize_into_acir( let ssa_level_warnings = if options.skip_underconstrained_check { vec![] } else { - time("After Check for Underconstrained Values", options.print_codegen_timings, || ssa.check_for_underconstrained_values()) + time("After Check for Underconstrained Values", options.print_codegen_timings, || { + ssa.check_for_underconstrained_values() + }) }; let brillig = time("SSA to Brillig", options.print_codegen_timings, || { ssa.to_brillig(options.enable_brillig_logging)