Skip to content

Commit

Permalink
enable the ability to toggle off the underconstrained check
Browse files Browse the repository at this point in the history
  • Loading branch information
vezenovm committed Aug 14, 2024
1 parent 86de991 commit 7c42c62
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
7 changes: 7 additions & 0 deletions compiler/noirc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExpressionWidth, std::io::Error> {
Expand Down Expand Up @@ -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, .. } =
Expand Down
9 changes: 8 additions & 1 deletion compiler/noirc_evaluator/src/ssa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ pub struct SsaEvaluatorOptions {

/// Dump the unoptimized SSA to the supplied path if it exists
pub emit_ssa: Option<PathBuf>,

/// Skip the check for under constrained values
pub skip_underconstrained_check: bool,
}

pub(crate) struct ArtifactsAndWarnings(Artifacts, Vec<SsaReport>);
Expand Down Expand Up @@ -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)
});
Expand Down
1 change: 1 addition & 0 deletions cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@
"typevar",
"typevars",
"udiv",
"underconstrained",
"uninstantiated",
"unnormalized",
"unoptimized",
Expand Down

0 comments on commit 7c42c62

Please sign in to comment.