fuzzgen: Panic on failed NaN Canonicalization pass (#4896)

This should never fail anyway, but it's good to know that we
aren't accidentally ignoring an input
This commit is contained in:
Afonso Bordado
2022-09-12 17:08:48 +01:00
committed by GitHub
parent 71fd873946
commit bb3aae740a

View File

@@ -166,7 +166,7 @@ where
Ok(inputs) Ok(inputs)
} }
fn run_func_passes(&self, func: Function) -> Result<Function> { fn run_func_passes(&self, func: Function) -> Function {
// Do a NaN Canonicalization pass on the generated function. // Do a NaN Canonicalization pass on the generated function.
// //
// Both IEEE754 and the Wasm spec are somewhat loose about what is allowed // Both IEEE754 and the Wasm spec are somewhat loose about what is allowed
@@ -189,16 +189,18 @@ where
let flags = settings::Flags::new(settings::builder()); let flags = settings::Flags::new(settings::builder());
let isa = builder_with_options(false) let isa = builder_with_options(false)
.expect("Unable to build a TargetIsa for the current host") .expect("Unable to build a TargetIsa for the current host")
.finish(flags)?; .finish(flags)
.expect("Failed to build TargetISA");
ctx.canonicalize_nans(isa.as_ref())?; ctx.canonicalize_nans(isa.as_ref())
.expect("Failed validation after NaN canonicalization");
Ok(ctx.func) ctx.func
} }
fn generate_func(&mut self) -> Result<Function> { fn generate_func(&mut self) -> Result<Function> {
let func = FunctionGenerator::new(&mut self.u, &self.config).generate()?; let func = FunctionGenerator::new(&mut self.u, &self.config).generate()?;
self.run_func_passes(func) Ok(self.run_func_passes(func))
} }
pub fn generate_test(mut self) -> Result<TestCase> { pub fn generate_test(mut self) -> Result<TestCase> {