Skip to content

Commit d4dd238

Browse files
committed
fuzzgen: Minimize regalloc_checker compiles
1 parent 3df5dfb commit d4dd238

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

cranelift/fuzzgen/src/config.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use std::collections::HashMap;
12
use std::ops::RangeInclusive;
23

34
/// Holds the range of acceptable values to use during the generation of testcases
@@ -54,6 +55,11 @@ pub struct Config {
5455
/// We insert a checking sequence to guarantee that those inputs never make
5556
/// it to the instruction, but sometimes we want to allow them.
5657
pub allowed_fcvt_traps_ratio: (usize, usize),
58+
59+
/// Some flags really impact compile performance, we still want to test
60+
/// them, but probably at a lower rate, so that overall execution time isn't
61+
/// impacted as much
62+
pub compile_flag_ratio: HashMap<&'static str, (usize, usize)>,
5763
}
5864

5965
impl Default for Config {
@@ -79,6 +85,7 @@ impl Default for Config {
7985
backwards_branch_ratio: (1, 1000),
8086
allowed_int_divz_ratio: (1, 1_000_000),
8187
allowed_fcvt_traps_ratio: (1, 1_000_000),
88+
compile_flag_ratio: [("regalloc_checker", (1usize, 100))].into_iter().collect(),
8289
}
8390
}
8491
}

cranelift/fuzzgen/src/lib.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,14 @@ where
257257
"enable_llvm_abi_extensions",
258258
];
259259
for flag_name in bool_settings {
260-
let value = format!("{}", bool::arbitrary(self.u)?);
260+
let enabled = self
261+
.config
262+
.compile_flag_ratio
263+
.get(&flag_name)
264+
.map(|&(num, denum)| self.u.ratio(num, denum))
265+
.unwrap_or_else(|| bool::arbitrary(self.u))?;
266+
267+
let value = format!("{}", enabled);
261268
builder.set(flag_name, value.as_str())?;
262269
}
263270

0 commit comments

Comments
 (0)