fuzzgen: Fuzz ISA flags (#6001)

This commit is contained in:
Afonso Bordado
2023-03-22 11:09:00 +00:00
committed by GitHub
parent 1ed7c89e3d
commit 3957d577b7
4 changed files with 102 additions and 4 deletions

View File

@@ -179,9 +179,10 @@ impl TestCase {
// TestCase is meant to be consumed by a runner, so we make the assumption here that we're
// generating a TargetIsa for the host.
let builder =
let mut builder =
builder_with_options(true).expect("Unable to build a TargetIsa for the current host");
let flags = gen.generate_flags(builder.triple().architecture)?;
gen.set_isa_flags(&mut builder, IsaFlagGen::Host)?;
let isa = builder.finish(flags)?;
// When generating functions, we allow each function to call any function that has

View File

@@ -48,13 +48,15 @@ impl FunctionWithIsa {
// a supported one, so that the same fuzz input works across different build
// configurations.
let target = u.choose(isa::ALL_ARCHITECTURES)?;
let builder = isa::lookup_by_name(target).map_err(|_| arbitrary::Error::IncorrectFormat)?;
let mut builder =
isa::lookup_by_name(target).map_err(|_| arbitrary::Error::IncorrectFormat)?;
let architecture = builder.triple().architecture;
let mut gen = FuzzGen::new(u);
let flags = gen
.generate_flags(architecture)
.map_err(|_| arbitrary::Error::IncorrectFormat)?;
gen.set_isa_flags(&mut builder, IsaFlagGen::All)?;
let isa = builder
.finish(flags)
.map_err(|_| arbitrary::Error::IncorrectFormat)?;