Skip to content

Commit

Permalink
fuzzgen: Add bb_padding_log2 option (#6575)
Browse files Browse the repository at this point in the history
  • Loading branch information
afonso360 authored Jun 13, 2023
1 parent aef1f57 commit 1d60443
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cranelift/fuzzgen/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ pub struct Config {
/// 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)>,

/// Range of values for the padding between basic blocks. Larger values will
/// generate larger functions.
pub bb_padding_log2_size: RangeInclusive<usize>,
}

impl Default for Config {
Expand Down Expand Up @@ -101,6 +105,11 @@ impl Default for Config {
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(),
// Generate up to 4KiB of padding between basic blocks. Although we only
// explicitly generate up to 16 blocks, after SSA construction we can
// end up with way more blocks than that (Seeing 400 blocks is not uncommon).
// At 4KiB we end up at around 1.5MiB of padding per function, which seems reasonable.
bb_padding_log2_size: 0..=12,
}
}
}
6 changes: 6 additions & 0 deletions cranelift/fuzzgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,12 @@ where
builder.set("probestack_size_log2", &format!("{}", size))?;
}

// Generate random basic block padding
let bb_padding = self
.u
.int_in_range(self.config.bb_padding_log2_size.clone())?;
builder.set("bb_padding_log2_minus_one", &format!("{}", bb_padding))?;

// Fixed settings

// We need llvm ABI extensions for i128 values on x86, so enable it regardless of
Expand Down

0 comments on commit 1d60443

Please sign in to comment.