fuzzgen: Disable verifier after NaN Canonicalization (#4914)

* fuzzgen: Disable verifier after NaN Canonicalization

We are currently running the verifier twice, once after the nan canonicalization pass, and again when JIT compiling the code.

The verifier first runs in the NaN Canonicalization pass. If it fails it prevents us from getting a nice `cargo fuzz fmt` test case.

So disable the verifier there, but ensure its enabled when JIT compiling.

* fuzzgen: Force enable verifier in cranelift-icache

This is already the default, but since we no longer run the verifier in `fuzzgen` its important to ensure that it runs in the fuzz targets.
This commit is contained in:
Afonso Bordado
2022-09-15 18:18:15 +01:00
committed by GitHub
parent d0b98aa25f
commit 2db7d7a8e0
3 changed files with 19 additions and 5 deletions

View File

@@ -183,17 +183,23 @@ where
// the interpreter won't get that version, so call that pass manually here. // the interpreter won't get that version, so call that pass manually here.
let mut ctx = Context::for_function(func); let mut ctx = Context::for_function(func);
// Assume that we are generating this function for the current ISA // Assume that we are generating this function for the current ISA.
// this is only used for the verifier after `canonicalize_nans` so // We disable the verifier here, since if it fails it prevents a test case from
// it's not too important. // being generated and formatted by `cargo fuzz fmt`.
let flags = settings::Flags::new(settings::builder()); // We run the verifier before compiling the code, so it always gets verified.
let flags = settings::Flags::new({
let mut builder = settings::builder();
builder.set("enable_verifier", "false").unwrap();
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"); .expect("Failed to build TargetISA");
ctx.canonicalize_nans(isa.as_ref()) ctx.canonicalize_nans(isa.as_ref())
.expect("Failed validation after NaN canonicalization"); .expect("Failed NaN canonicalization pass");
ctx.func ctx.func
} }

View File

@@ -85,6 +85,10 @@ fuzz_target!(|testcase: TestCase| {
let mut builder = settings::builder(); let mut builder = settings::builder();
// We need llvm ABI extensions for i128 values on x86 // We need llvm ABI extensions for i128 values on x86
builder.set("enable_llvm_abi_extensions", "true").unwrap(); builder.set("enable_llvm_abi_extensions", "true").unwrap();
// This is the default, but we should ensure that it wasn't accidentally turned off anywhere.
builder.set("enable_verifier", "true").unwrap();
settings::Flags::new(builder) settings::Flags::new(builder)
}; };
let mut compiler = TestFileCompiler::with_host_isa(flags).unwrap(); let mut compiler = TestFileCompiler::with_host_isa(flags).unwrap();

View File

@@ -20,6 +20,10 @@ fuzz_target!(|func: SingleFunction| {
let mut builder = settings::builder(); let mut builder = settings::builder();
// We need llvm ABI extensions for i128 values on x86 // We need llvm ABI extensions for i128 values on x86
builder.set("enable_llvm_abi_extensions", "true").unwrap(); builder.set("enable_llvm_abi_extensions", "true").unwrap();
// This is the default, but we should ensure that it wasn't accidentally turned off anywhere.
builder.set("enable_verifier", "true").unwrap();
builder builder
}); });