Skip to content

Commit 4d75ebd

Browse files
authored
Fuzzing: Keep AVX flags enabled for Winch (bytecodealliance#10052)
* Fuzzing: Keep AVX flags enabled for Winch * Check that SIMD is enabled * Inspect flags in wast oracle * Add log statement
1 parent a018a5a commit 4d75ebd

File tree

3 files changed

+40
-1
lines changed

3 files changed

+40
-1
lines changed

crates/fuzzing/src/generators/codegen_settings.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ impl CodegenSettings {
3131
}
3232
}
3333
}
34+
35+
/// Returns the flags used for codegen.
36+
pub(crate) fn flags(&self) -> &[(String, String)] {
37+
if let Self::Target { flags, .. } = self {
38+
flags
39+
} else {
40+
&[]
41+
}
42+
}
3443
}
3544

3645
impl<'a> Arbitrary<'a> for CodegenSettings {

crates/fuzzing/src/generators/config.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -685,6 +685,17 @@ impl WasmtimeConfig {
685685
Ok(())
686686
}
687687

688+
/// Returns the codegen flag value, if any, for `name`.
689+
pub(crate) fn codegen_flag(&self, name: &str) -> Option<&str> {
690+
self.codegen.flags().iter().find_map(|(n, value)| {
691+
if n == name {
692+
Some(value.as_str())
693+
} else {
694+
None
695+
}
696+
})
697+
}
698+
688699
/// Helper to switch `MemoryConfig::CustomUnaligned` to
689700
/// `MemoryConfig::Normal`
690701
fn avoid_custom_unaligned_memory(&mut self, u: &mut Unstructured<'_>) -> arbitrary::Result<()> {

crates/fuzzing/src/oracles.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ mod stacks;
2121

2222
use self::diff_wasmtime::WasmtimeInstance;
2323
use self::engine::{DiffEngine, DiffInstance};
24-
use crate::generators::{self, DiffValue, DiffValueType};
24+
use crate::generators::{self, CompilerStrategy, DiffValue, DiffValueType};
2525
use crate::single_module_fuzzer::KnownValid;
2626
use arbitrary::Arbitrary;
2727
pub use stacks::check_stacks;
@@ -672,6 +672,25 @@ pub fn wast_test(mut fuzz_config: generators::Config, test: generators::WastTest
672672
return;
673673
}
674674

675+
// Winch requires AVX and AVX2 for SIMD tests to pass so don't run the test
676+
// if either isn't enabled.
677+
if fuzz_config.wasmtime.compiler_strategy == CompilerStrategy::Winch
678+
&& test.config.simd()
679+
&& (fuzz_config
680+
.wasmtime
681+
.codegen_flag("has_avx")
682+
.is_some_and(|value| value == "false")
683+
|| fuzz_config
684+
.wasmtime
685+
.codegen_flag("has_avx2")
686+
.is_some_and(|value| value == "false"))
687+
{
688+
log::warn!(
689+
"Skipping Wast test because Winch doesn't support SIMD tests with AVX or AVX2 disabled"
690+
);
691+
return;
692+
}
693+
675694
// Fuel and epochs don't play well with threads right now, so exclude any
676695
// thread-spawning test if it looks like threads are spawned in that case.
677696
if fuzz_config.wasmtime.consume_fuel || fuzz_config.wasmtime.epoch_interruption {

0 commit comments

Comments
 (0)