Keep internal modules private, but re-export under fuzzing feature flag

This commit is contained in:
Chris Fallin
2021-06-19 12:08:37 -07:00
parent caf7274efd
commit 50eb6fc42f
7 changed files with 47 additions and 20 deletions

View File

@@ -8,7 +8,10 @@ use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
use libfuzzer_sys::fuzz_target;
use std::collections::HashSet;
use regalloc2::{domtree, postorder, Block};
use regalloc2::{
fuzzing::{domtree, postorder},
Block,
};
#[derive(Clone, Debug)]
struct CFG {
@@ -96,7 +99,10 @@ fn check_idom_violations(idom: &[Block], path: &Path) {
// and false for every other block.
for domblock in 0..idom.len() {
let domblock = Block::new(domblock);
assert_eq!(domset.contains(&domblock), domtree::dominates(idom, domblock, *block));
assert_eq!(
domset.contains(&domblock),
domtree::dominates(idom, domblock, *block)
);
}
visited.insert(*block);
}
@@ -112,10 +118,7 @@ impl Arbitrary for TestCase {
fn arbitrary(u: &mut Unstructured) -> Result<TestCase> {
let cfg = CFG::arbitrary(u)?;
let path = Path::choose_from_cfg(&cfg, u)?;
Ok(TestCase {
cfg,
path,
})
Ok(TestCase { cfg, path })
}
}

View File

@@ -12,5 +12,5 @@ fuzz_target!(|func: Func| {
let _ = env_logger::try_init();
log::debug!("func:\n{:?}", func);
let env = regalloc2::fuzzing::func::machine_env();
let _out = regalloc2::ion::run(&func, &env, false).expect("regalloc did not succeed");
let _out = regalloc2::fuzzing::ion::run(&func, &env, false).expect("regalloc did not succeed");
});

View File

@@ -7,7 +7,7 @@
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
use libfuzzer_sys::fuzz_target;
use regalloc2::checker::Checker;
use regalloc2::fuzzing::checker::Checker;
use regalloc2::fuzzing::func::{Func, Options};
#[derive(Clone, Debug)]
@@ -40,7 +40,7 @@ fuzz_target!(|testcase: TestCase| {
let _ = env_logger::try_init();
log::debug!("func:\n{:?}", func);
let env = regalloc2::fuzzing::func::machine_env();
let out = regalloc2::ion::run(&func, &env, true).expect("regalloc did not succeed");
let out = regalloc2::fuzzing::ion::run(&func, &env, true).expect("regalloc did not succeed");
let mut checker = Checker::new(&func);
checker.prepare(&out);

View File

@@ -7,7 +7,7 @@
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
use libfuzzer_sys::fuzz_target;
use regalloc2::moves::ParallelMoves;
use regalloc2::fuzzing::moves::ParallelMoves;
use regalloc2::{Allocation, PReg, RegClass};
use std::collections::HashSet;

View File

@@ -7,9 +7,9 @@
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
use libfuzzer_sys::fuzz_target;
use regalloc2::cfg::CFGInfo;
use regalloc2::fuzzing::cfg::CFGInfo;
use regalloc2::fuzzing::func::{Func, Options};
use regalloc2::ssa::validate_ssa;
use regalloc2::fuzzing::ssa::validate_ssa;
#[derive(Debug)]
struct TestCase {