Skip to content

Commit

Permalink
settings: set checked_operations to false when optimisation_level
Browse files Browse the repository at this point in the history
… > `release`
  • Loading branch information
Alexander Fedotov committed Apr 14, 2024
1 parent 6eab36d commit 69fe2a7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
19 changes: 17 additions & 2 deletions compiler/hash-pipeline/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,12 @@ impl CompilerSettings {
Self::default()
}

pub fn new_from_args() -> Self {
let mut this = Self::parse();
this.apply_optimisation_level(this.optimisation_level);
this
}

/// Get the entry point filename from the [CompilerSettings]. If
/// [`None`] was provided, it is assumed that this is then an interactive
/// session.
Expand Down Expand Up @@ -202,9 +208,18 @@ impl CompilerSettings {
/// `checked_operations` are disabled.
pub fn set_optimisation_level(&mut self, level: OptimisationLevel) {
self.optimisation_level = level;
self.apply_optimisation_level(level);
}

if self.optimisation_level == OptimisationLevel::Release {
self.lowering_settings.checked_operations = false;
pub fn apply_optimisation_level(&mut self, level: OptimisationLevel) {
match level {
OptimisationLevel::Debug => {
self.lowering_settings.checked_operations = true;
}
OptimisationLevel::Release => {
self.lowering_settings.checked_operations = false;
}
OptimisationLevel::Size | OptimisationLevel::MinSize => {}
}
}

Expand Down
4 changes: 2 additions & 2 deletions compiler/hash/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::panic;

use hash_driver::CompilerBuilder;
use hash_pipeline::settings::CompilerSettings;
use hash_utils::{clap::Parser, crash::crash_handler, log, logging::CompilerLogger};
use hash_utils::{crash::crash_handler, log, logging::CompilerLogger};

/// The logger that is used by the compiler for `log!` statements.
pub static COMPILER_LOGGER: CompilerLogger = CompilerLogger;
Expand All @@ -20,7 +20,7 @@ fn main() {
// Register main thread with the profiler
profiling::register_thread!("compiler-main");

let settings = CompilerSettings::parse();
let settings = CompilerSettings::new_from_args();

// if debug is specified, we want to log everything that is debug level...
if settings.debug {
Expand Down

0 comments on commit 69fe2a7

Please sign in to comment.