/src/regalloc2/fuzz/fuzz_targets/ion_checker.rs
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Released under the terms of the Apache 2.0 license with LLVM |
3 | | * exception. See `LICENSE` for details. |
4 | | */ |
5 | | |
6 | | #![no_main] |
7 | | use regalloc2::fuzzing::arbitrary::{Arbitrary, Result, Unstructured}; |
8 | | use regalloc2::fuzzing::checker::Checker; |
9 | | use regalloc2::fuzzing::func::{Func, Options}; |
10 | | use regalloc2::fuzzing::fuzz_target; |
11 | | |
12 | 0 | #[derive(Clone, Debug)] |
13 | | struct TestCase { |
14 | | func: Func, |
15 | | } |
16 | | |
17 | | impl Arbitrary<'_> for TestCase { |
18 | 9.54k | fn arbitrary(u: &mut Unstructured) -> Result<TestCase> { |
19 | 9.54k | Ok(TestCase { |
20 | 9.54k | func: Func::arbitrary_with_options( |
21 | 9.54k | u, |
22 | 9.54k | &Options { |
23 | 9.54k | reused_inputs: true, |
24 | 9.54k | fixed_regs: true, |
25 | 9.54k | fixed_nonallocatable: true, |
26 | 9.54k | clobbers: true, |
27 | 9.54k | control_flow: true, |
28 | 9.54k | reducible: false, |
29 | 9.54k | block_params: true, |
30 | 9.54k | always_local_uses: false, |
31 | 9.54k | reftypes: true, |
32 | 9.54k | }, |
33 | 9.54k | )?, |
34 | | }) |
35 | 9.54k | } |
36 | | } |
37 | | |
38 | | fuzz_target!(|testcase: TestCase| { |
39 | | let func = testcase.func; |
40 | | let _ = env_logger::try_init(); |
41 | | log::trace!("func:\n{:?}", func); |
42 | | let env = regalloc2::fuzzing::func::machine_env(); |
43 | | let out = |
44 | | regalloc2::fuzzing::ion::run(&func, &env, true, false).expect("regalloc did not succeed"); |
45 | | |
46 | | let mut checker = Checker::new(&func, &env); |
47 | | checker.prepare(&out); |
48 | | checker.run().expect("checker failed"); |
49 | | }); |