-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathfastalloc_checker.rs
More file actions
46 lines (41 loc) · 1.3 KB
/
fastalloc_checker.rs
File metadata and controls
46 lines (41 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
* Released under the terms of the Apache 2.0 license with LLVM
* exception. See `LICENSE` for details.
*/
#![no_main]
use regalloc2::fuzzing::arbitrary::{Arbitrary, Result, Unstructured};
use regalloc2::fuzzing::checker::Checker;
use regalloc2::fuzzing::func::{Func, Options};
use regalloc2::fuzzing::fuzz_target;
#[derive(Clone, Debug)]
struct TestCase {
func: Func,
}
impl Arbitrary<'_> for TestCase {
fn arbitrary(u: &mut Unstructured) -> Result<TestCase> {
Ok(TestCase {
func: Func::arbitrary_with_options(
u,
&Options {
reused_inputs: true,
fixed_regs: true,
fixed_nonallocatable: true,
clobbers: true,
reftypes: false,
},
)?,
})
}
}
fuzz_target!(|testcase: TestCase| {
let func = testcase.func;
let _ = env_logger::try_init();
log::trace!("func:\n{:?}", func);
let env = regalloc2::fuzzing::func::machine_env();
let out =
regalloc2::fuzzing::fastalloc::run(&func, &env, true, false).expect("regalloc did not succeed");
let mut checker = Checker::new(&func, &env);
checker.prepare(&out);
checker.init_debug_locations(&out);
checker.run().expect("checker failed");
});