Skip to content

Commit 7d90ca9

Browse files
authored
Remove unused function generator options (#163)
* Remove unused function generation options * Avoid uses of `Vec::last_mut`
1 parent 6ba8cab commit 7d90ca9

File tree

3 files changed

+9
-42
lines changed

3 files changed

+9
-42
lines changed

fuzz/fuzz_targets/ion_checker.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ impl Arbitrary<'_> for TestCase {
2424
fixed_regs: true,
2525
fixed_nonallocatable: true,
2626
clobbers: true,
27-
control_flow: true,
28-
reducible: false,
29-
block_params: true,
30-
always_local_uses: false,
3127
reftypes: true,
3228
},
3329
)?,

fuzz/fuzz_targets/ssagen.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ impl Arbitrary<'_> for TestCase {
2525
fixed_regs: true,
2626
fixed_nonallocatable: true,
2727
clobbers: true,
28-
control_flow: true,
29-
reducible: false,
30-
always_local_uses: false,
31-
block_params: true,
3228
reftypes: true,
3329
},
3430
)?,

src/fuzzing/func.rs

Lines changed: 9 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,6 @@ pub struct Options {
267267
pub fixed_regs: bool,
268268
pub fixed_nonallocatable: bool,
269269
pub clobbers: bool,
270-
pub control_flow: bool,
271-
pub reducible: bool,
272-
pub block_params: bool,
273-
pub always_local_uses: bool,
274270
pub reftypes: bool,
275271
}
276272

@@ -281,10 +277,6 @@ impl core::default::Default for Options {
281277
fixed_regs: false,
282278
fixed_nonallocatable: false,
283279
clobbers: false,
284-
control_flow: true,
285-
reducible: false,
286-
block_params: true,
287-
always_local_uses: false,
288280
reftypes: false,
289281
}
290282
}
@@ -322,12 +314,9 @@ impl Func {
322314
let mut from = 0;
323315
let mut out_blocks = vec![];
324316
let mut in_blocks = vec![];
325-
// For reducibility, if selected: enforce strict nesting of backedges
326-
let mut max_backedge_src = 0;
327-
let mut min_backedge_dest = num_blocks;
328317
while from < num_blocks {
329318
in_blocks.push(from);
330-
if num_blocks > 3 && from < num_blocks - 3 && bool::arbitrary(u)? && opts.control_flow {
319+
if num_blocks > 3 && from < num_blocks - 3 && bool::arbitrary(u)? {
331320
// To avoid critical edges, we use from+1 as an edge
332321
// block, and advance `from` an extra block; `from+2`
333322
// will be the next normal iteration.
@@ -342,18 +331,7 @@ impl Func {
342331
from += 1;
343332
}
344333
for pred in out_blocks {
345-
let mut succ = *u.choose(&in_blocks[..])?;
346-
if opts.reducible && (pred >= succ) {
347-
if pred < max_backedge_src || succ > min_backedge_dest {
348-
// If the chosen edge would result in an
349-
// irreducible CFG, just make this a diamond
350-
// instead.
351-
succ = pred + 2;
352-
} else {
353-
max_backedge_src = pred;
354-
min_backedge_dest = succ;
355-
}
356-
}
334+
let succ = *u.choose(&in_blocks[..])?;
357335
builder.add_edge(Block::new(pred), Block::new(succ));
358336
}
359337

@@ -402,17 +380,18 @@ impl Func {
402380
}
403381
}
404382
vregs_by_block.push(vregs.clone());
405-
vregs_by_block_to_be_defined.push(vec![]);
383+
let mut vregs_to_be_defined = vec![];
406384
let mut max_block_params = u.int_in_range(0..=core::cmp::min(3, vregs.len() / 3))?;
407385
for &vreg in &vregs {
408-
if block > 0 && opts.block_params && bool::arbitrary(u)? && max_block_params > 0 {
386+
if block > 0 && bool::arbitrary(u)? && max_block_params > 0 {
409387
block_params[block].push(vreg);
410388
max_block_params -= 1;
411389
} else {
412-
vregs_by_block_to_be_defined.last_mut().unwrap().push(vreg);
390+
vregs_to_be_defined.push(vreg);
413391
}
414392
}
415-
vregs_by_block_to_be_defined.last_mut().unwrap().reverse();
393+
vregs_to_be_defined.reverse();
394+
vregs_by_block_to_be_defined.push(vregs_to_be_defined);
416395
builder.set_block_params_in(Block::new(block), &block_params[block][..]);
417396
}
418397

@@ -435,12 +414,10 @@ impl Func {
435414
let mut allocations = vec![Allocation::none()];
436415
for _ in 0..u.int_in_range(0..=3)? {
437416
let vreg = if avail.len() > 0
438-
&& (opts.always_local_uses
439-
|| remaining_nonlocal_uses == 0
440-
|| bool::arbitrary(u)?)
417+
&& (remaining_nonlocal_uses == 0 || bool::arbitrary(u)?)
441418
{
442419
*u.choose(&avail[..])?
443-
} else if !opts.always_local_uses {
420+
} else {
444421
let def_block = choose_dominating_block(
445422
&builder.idom[..],
446423
Block::new(block),
@@ -454,8 +431,6 @@ impl Func {
454431
}
455432
remaining_nonlocal_uses -= 1;
456433
*u.choose(&vregs_by_block[def_block.index()])?
457-
} else {
458-
break;
459434
};
460435
let use_constraint = OperandConstraint::arbitrary(u)?;
461436
operands.push(Operand::new(

0 commit comments

Comments
 (0)