fuzzgen: Generate compiler flags (#5020)

* fuzzgen: Test compiler flags

* cranelift: Generate `all()` function for all enum flags

This allows a user to iterate all flags that exist.

* fuzzgen: Minimize regalloc_checker compiles

* fuzzgen: Limit the amount of test case inputs

* fuzzgen: Add egraphs flag

It's finally here! 🥳

* cranelift: Add fuzzing comment to settings

* fuzzgen: Add riscv64

* fuzzgen:  Unconditionally enable some flags
This commit is contained in:
Afonso Bordado
2022-10-21 00:40:50 +01:00
committed by GitHub
parent 0959f90755
commit 51d8734235
5 changed files with 138 additions and 29 deletions

View File

@@ -1,8 +1,13 @@
use std::collections::HashMap;
use std::ops::RangeInclusive;
/// Holds the range of acceptable values to use during the generation of testcases
pub struct Config {
pub test_case_inputs: RangeInclusive<usize>,
/// Maximum allowed test case inputs.
/// We build test case inputs from the rest of the bytes that the fuzzer provides us
/// so we allow the fuzzer to control this by feeding us more or less bytes.
/// The upper bound here is to prevent too many inputs that cause long test times
pub max_test_case_inputs: usize,
pub signature_params: RangeInclusive<usize>,
pub signature_rets: RangeInclusive<usize>,
pub instructions_per_block: RangeInclusive<usize>,
@@ -51,12 +56,17 @@ pub struct Config {
/// We insert a checking sequence to guarantee that those inputs never make
/// it to the instruction, but sometimes we want to allow them.
pub allowed_fcvt_traps_ratio: (usize, usize),
/// Some flags really impact compile performance, we still want to test
/// them, but probably at a lower rate, so that overall execution time isn't
/// impacted as much
pub compile_flag_ratio: HashMap<&'static str, (usize, usize)>,
}
impl Default for Config {
fn default() -> Self {
Config {
test_case_inputs: 1..=10,
max_test_case_inputs: 100,
signature_params: 0..=16,
signature_rets: 0..=16,
instructions_per_block: 0..=64,
@@ -75,6 +85,7 @@ impl Default for Config {
backwards_branch_ratio: (1, 1000),
allowed_int_divz_ratio: (1, 1_000_000),
allowed_fcvt_traps_ratio: (1, 1_000_000),
compile_flag_ratio: [("regalloc_checker", (1usize, 1000))].into_iter().collect(),
}
}
}