Skip to content

Commit

Permalink
Add CompilerConifg opt to disable IR verification in debug mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark McCaskey committed Mar 24, 2020
1 parent 56aec04 commit 7d59fb4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
16 changes: 11 additions & 5 deletions lib/clif-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,22 @@ fn get_isa(config: Option<&CompilerConfig>) -> Box<dyn isa::TargetIsa> {
builder.set("opt_level", "speed_and_size").unwrap();
builder.set("enable_jump_tables", "false").unwrap();

if cfg!(test) || cfg!(debug_assertions) {
builder.set("enable_verifier", "true").unwrap();
} else {
builder.set("enable_verifier", "false").unwrap();
}
let enable_verifier: bool;

if let Some(config) = config {
if config.nan_canonicalization {
builder.set("enable_nan_canonicalization", "true").unwrap();
}
enable_verifier = !config.disable_debug_mode_verification;
} else {
// Set defaults if no config found.
enable_verifier = true;
}

if (cfg!(test) || cfg!(debug_assertions)) && enable_verifier {
builder.set("enable_verifier", "true").unwrap();
} else {
builder.set("enable_verifier", "false").unwrap();
}

let flags = settings::Flags::new(builder);
Expand Down
16 changes: 8 additions & 8 deletions lib/clif-backend/src/trampoline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl Trampolines {
let sig_index = module.func_assoc[*exported_func_index];
let func_sig = &module.signatures[sig_index];

let trampoline_func = generate_func(&func_sig);
let trampoline_func = generate_func(isa, &func_sig);

ctx.func = trampoline_func;

Expand Down Expand Up @@ -150,13 +150,13 @@ impl Trampolines {

/// This function generates a trampoline for the specific signature
/// passed into it.
fn generate_func(func_sig: &FuncSig) -> ir::Function {
let trampoline_sig = generate_trampoline_signature();
fn generate_func(isa: &dyn isa::TargetIsa, func_sig: &FuncSig) -> ir::Function {
let trampoline_sig = generate_trampoline_signature(isa);

let mut func =
ir::Function::with_name_signature(ir::ExternalName::testcase("trampln"), trampoline_sig);

let export_sig_ref = func.import_signature(generate_export_signature(func_sig));
let export_sig_ref = func.import_signature(generate_export_signature(isa, func_sig));

let entry_ebb = func.dfg.make_block();
let vmctx_ptr = func.dfg.append_block_param(entry_ebb, ir::types::I64);
Expand Down Expand Up @@ -211,8 +211,8 @@ fn wasm_ty_to_clif(ty: Type) -> ir::types::Type {
}
}

fn generate_trampoline_signature() -> ir::Signature {
let call_convention = super::get_isa(None).default_call_conv();
fn generate_trampoline_signature(isa: &dyn isa::TargetIsa) -> ir::Signature {
let call_convention = isa.default_call_conv();
let mut sig = ir::Signature::new(call_convention);

let ptr_param = ir::AbiParam {
Expand All @@ -227,8 +227,8 @@ fn generate_trampoline_signature() -> ir::Signature {
sig
}

fn generate_export_signature(func_sig: &FuncSig) -> ir::Signature {
let call_convention = super::get_isa(None).default_call_conv();
fn generate_export_signature(isa: &dyn isa::TargetIsa, func_sig: &FuncSig) -> ir::Signature {
let call_convention = isa.default_call_conv();
let mut export_clif_sig = ir::Signature::new(call_convention);

let func_sig_iter = func_sig.params().iter().map(|wasm_ty| ir::AbiParam {
Expand Down
6 changes: 6 additions & 0 deletions lib/runtime-core/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ pub struct CompilerConfig {
/// Enabling this makes execution deterministic but increases runtime overhead.
pub nan_canonicalization: bool,

/// Turns off verification that is done by default when `debug_assertions` are enabled
/// (for example in 'debug' builds). Enabling this flag will make compilation faster at the
/// cost of not detecting bugs in the compiler. The verification steps that this flag
/// disables are disabled by default in 'release' builds.
pub disable_debug_mode_verification: bool,

pub features: Features,

// Target info. Presently only supported by LLVM.
Expand Down

0 comments on commit 7d59fb4

Please sign in to comment.