Skip to content

Commit 4f0eb75

Browse files
committed
Merge branch 'main' into less-fuzz-work
2 parents 85eef64 + 67677b1 commit 4f0eb75

File tree

15 files changed

+347
-173
lines changed

15 files changed

+347
-173
lines changed

fuzz/fuzz_targets/fastalloc_checker.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ impl Arbitrary<'_> for TestCase {
2626
clobbers: true,
2727
reftypes: false,
2828
callsite_ish_constraints: true,
29+
..Options::default()
2930
},
3031
)?,
3132
})
@@ -37,8 +38,8 @@ fuzz_target!(|testcase: TestCase| {
3738
let _ = env_logger::try_init();
3839
log::trace!("func:\n{:?}", func);
3940
let env = regalloc2::fuzzing::func::machine_env();
40-
let out =
41-
regalloc2::fuzzing::fastalloc::run(&func, &env, true, false).expect("regalloc did not succeed");
41+
let out = regalloc2::fuzzing::fastalloc::run(&func, &env, true, false)
42+
.expect("regalloc did not succeed");
4243

4344
let mut checker = Checker::new(&func, &env);
4445
checker.prepare(&out);

fuzz/fuzz_targets/ion_checker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ impl Arbitrary<'_> for TestCase {
2626
clobbers: true,
2727
reftypes: true,
2828
callsite_ish_constraints: true,
29+
..Options::default()
2930
},
3031
)?,
3132
})

fuzz/fuzz_targets/ssagen.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ impl Arbitrary<'_> for TestCase {
2727
clobbers: true,
2828
reftypes: true,
2929
callsite_ish_constraints: true,
30+
..Options::default()
3031
},
3132
)?,
3233
})

src/checker.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ use alloc::vec::Vec;
104104
use alloc::{format, vec};
105105
use core::default::Default;
106106
use core::hash::Hash;
107+
use core::ops::Range;
107108
use core::result::Result;
108109
use smallvec::{smallvec, SmallVec};
109110

@@ -166,6 +167,12 @@ pub enum CheckerError {
166167
into: Allocation,
167168
from: Allocation,
168169
},
170+
AllocationOutsideLimit {
171+
inst: Inst,
172+
op: Operand,
173+
alloc: Allocation,
174+
range: Range<usize>,
175+
},
169176
}
170177

171178
/// Abstract state for an allocation.
@@ -669,6 +676,18 @@ impl CheckerState {
669676
});
670677
}
671678
}
679+
OperandConstraint::Limit(max) => {
680+
if let Some(preg) = alloc.as_reg() {
681+
if preg.hw_enc() >= max {
682+
return Err(CheckerError::AllocationOutsideLimit {
683+
inst,
684+
op,
685+
alloc,
686+
range: (0..max),
687+
});
688+
}
689+
}
690+
}
672691
}
673692
Ok(())
674693
}

src/fastalloc/mod.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,9 @@ impl<'a, F: Function> Env<'a, F> {
618618
}
619619

620620
OperandConstraint::Stack => self.edits.is_stack(alloc),
621+
OperandConstraint::Limit(_) => {
622+
todo!("limit constraints are not yet supported in fastalloc")
623+
}
621624
}
622625
}
623626

@@ -773,6 +776,9 @@ impl<'a, F: Function> Env<'a, F> {
773776
}
774777

775778
OperandConstraint::Stack => Allocation::stack(self.get_spillslot(op.vreg())),
779+
OperandConstraint::Limit(_) => {
780+
todo!("limit constraints are not yet supported in fastalloc")
781+
}
776782
};
777783
self.allocs[(inst.index(), op_idx)] = new_alloc;
778784
Ok(new_alloc)

0 commit comments

Comments
 (0)