diff --git a/crates/fuzzing/src/generators/config.rs b/crates/fuzzing/src/generators/config.rs index 4b94f278b3..1029cd4b96 100644 --- a/crates/fuzzing/src/generators/config.rs +++ b/crates/fuzzing/src/generators/config.rs @@ -163,6 +163,7 @@ impl Config { .native_unwind_info(self.wasmtime.native_unwind_info) .cranelift_nan_canonicalization(self.wasmtime.canonicalize_nans) .cranelift_opt_level(self.wasmtime.opt_level.to_wasmtime()) + .cranelift_use_egraphs(self.wasmtime.use_egraphs) .consume_fuel(self.wasmtime.consume_fuel) .epoch_interruption(self.wasmtime.epoch_interruption) .memory_init_cow(self.wasmtime.memory_init_cow) @@ -303,9 +304,10 @@ impl Config { // Don't propagate these errors to prevent them from accidentally being // interpreted as invalid wasm, these should never fail on a // well-behaved host system. - let file = tempfile::NamedTempFile::new().unwrap(); - std::fs::write(file.path(), module.serialize().unwrap()).unwrap(); - unsafe { Ok(Module::deserialize_file(engine, file.path()).unwrap()) } + let dir = tempfile::TempDir::new().unwrap(); + let file = dir.path().join("module.wasm"); + std::fs::write(&file, module.serialize().unwrap()).unwrap(); + unsafe { Ok(Module::deserialize_file(engine, &file).unwrap()) } } } @@ -369,6 +371,7 @@ impl<'a> Arbitrary<'a> for Config { #[derive(Arbitrary, Clone, Debug, Eq, Hash, PartialEq)] pub struct WasmtimeConfig { opt_level: OptLevel, + use_egraphs: bool, debug_info: bool, canonicalize_nans: bool, interruptable: bool, diff --git a/crates/wasmtime/src/config.rs b/crates/wasmtime/src/config.rs index 54073aa834..e5f3fde341 100644 --- a/crates/wasmtime/src/config.rs +++ b/crates/wasmtime/src/config.rs @@ -853,6 +853,27 @@ impl Config { self } + /// Configures the Cranelift code generator to use its + /// "egraph"-based mid-end optimizer. + /// + /// This optimizer is intended to replace the compiler's more + /// traditional pipeline of optimization passes with a unified + /// code-rewriting system. It is not yet on by default, but it is + /// intended to become the default in a future version. It may + /// result in faster code, at the cost of slightly more + /// compilation-time work. + /// + /// The default value for this is `false`. + #[cfg(compiler)] + #[cfg_attr(nightlydoc, doc(cfg(feature = "cranelift")))] // see build.rs + pub fn cranelift_use_egraphs(&mut self, enable: bool) -> &mut Self { + let val = if enable { "true" } else { "false" }; + self.compiler_config + .settings + .insert("use_egraphs".to_string(), val.to_string()); + self + } + /// Configures whether Cranelift should perform a NaN-canonicalization pass. /// /// When Cranelift is used as a code generation backend this will configure