Keep internal modules private, but re-export under fuzzing feature flag
This commit is contained in:
@@ -8,7 +8,10 @@ use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
|
|||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::fuzz_target;
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
use regalloc2::{domtree, postorder, Block};
|
use regalloc2::{
|
||||||
|
fuzzing::{domtree, postorder},
|
||||||
|
Block,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
struct CFG {
|
struct CFG {
|
||||||
@@ -96,7 +99,10 @@ fn check_idom_violations(idom: &[Block], path: &Path) {
|
|||||||
// and false for every other block.
|
// and false for every other block.
|
||||||
for domblock in 0..idom.len() {
|
for domblock in 0..idom.len() {
|
||||||
let domblock = Block::new(domblock);
|
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);
|
visited.insert(*block);
|
||||||
}
|
}
|
||||||
@@ -112,10 +118,7 @@ impl Arbitrary for TestCase {
|
|||||||
fn arbitrary(u: &mut Unstructured) -> Result<TestCase> {
|
fn arbitrary(u: &mut Unstructured) -> Result<TestCase> {
|
||||||
let cfg = CFG::arbitrary(u)?;
|
let cfg = CFG::arbitrary(u)?;
|
||||||
let path = Path::choose_from_cfg(&cfg, u)?;
|
let path = Path::choose_from_cfg(&cfg, u)?;
|
||||||
Ok(TestCase {
|
Ok(TestCase { cfg, path })
|
||||||
cfg,
|
|
||||||
path,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,5 +12,5 @@ fuzz_target!(|func: Func| {
|
|||||||
let _ = env_logger::try_init();
|
let _ = env_logger::try_init();
|
||||||
log::debug!("func:\n{:?}", func);
|
log::debug!("func:\n{:?}", func);
|
||||||
let env = regalloc2::fuzzing::func::machine_env();
|
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");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
|
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::fuzz_target;
|
||||||
|
|
||||||
use regalloc2::checker::Checker;
|
use regalloc2::fuzzing::checker::Checker;
|
||||||
use regalloc2::fuzzing::func::{Func, Options};
|
use regalloc2::fuzzing::func::{Func, Options};
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@@ -40,7 +40,7 @@ fuzz_target!(|testcase: TestCase| {
|
|||||||
let _ = env_logger::try_init();
|
let _ = env_logger::try_init();
|
||||||
log::debug!("func:\n{:?}", func);
|
log::debug!("func:\n{:?}", func);
|
||||||
let env = regalloc2::fuzzing::func::machine_env();
|
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);
|
let mut checker = Checker::new(&func);
|
||||||
checker.prepare(&out);
|
checker.prepare(&out);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
|
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::fuzz_target;
|
||||||
|
|
||||||
use regalloc2::moves::ParallelMoves;
|
use regalloc2::fuzzing::moves::ParallelMoves;
|
||||||
use regalloc2::{Allocation, PReg, RegClass};
|
use regalloc2::{Allocation, PReg, RegClass};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
|
|
||||||
|
|||||||
@@ -7,9 +7,9 @@
|
|||||||
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
|
use libfuzzer_sys::arbitrary::{Arbitrary, Result, Unstructured};
|
||||||
use libfuzzer_sys::fuzz_target;
|
use libfuzzer_sys::fuzz_target;
|
||||||
|
|
||||||
use regalloc2::cfg::CFGInfo;
|
use regalloc2::fuzzing::cfg::CFGInfo;
|
||||||
use regalloc2::fuzzing::func::{Func, Options};
|
use regalloc2::fuzzing::func::{Func, Options};
|
||||||
use regalloc2::ssa::validate_ssa;
|
use regalloc2::fuzzing::ssa::validate_ssa;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
struct TestCase {
|
struct TestCase {
|
||||||
|
|||||||
@@ -6,3 +6,27 @@
|
|||||||
//! Utilities for fuzzing.
|
//! Utilities for fuzzing.
|
||||||
|
|
||||||
pub mod func;
|
pub mod func;
|
||||||
|
|
||||||
|
// Re-exports for fuzz targets.
|
||||||
|
|
||||||
|
pub mod domtree {
|
||||||
|
pub use crate::domtree::*;
|
||||||
|
}
|
||||||
|
pub mod postorder {
|
||||||
|
pub use crate::postorder::*;
|
||||||
|
}
|
||||||
|
pub mod moves {
|
||||||
|
pub use crate::moves::*;
|
||||||
|
}
|
||||||
|
pub mod cfg {
|
||||||
|
pub use crate::cfg::*;
|
||||||
|
}
|
||||||
|
pub mod ssa {
|
||||||
|
pub use crate::ssa::*;
|
||||||
|
}
|
||||||
|
pub mod ion {
|
||||||
|
pub use crate::ion::*;
|
||||||
|
}
|
||||||
|
pub mod checker {
|
||||||
|
pub use crate::checker::*;
|
||||||
|
}
|
||||||
|
|||||||
16
src/lib.rs
16
src/lib.rs
@@ -12,16 +12,16 @@
|
|||||||
|
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
|
|
||||||
pub mod bitvec;
|
pub(crate) mod bitvec;
|
||||||
pub mod cfg;
|
pub(crate) mod cfg;
|
||||||
pub mod domtree;
|
pub(crate) mod domtree;
|
||||||
pub mod ion;
|
pub(crate) mod ion;
|
||||||
pub mod moves;
|
pub(crate) mod moves;
|
||||||
pub mod postorder;
|
pub(crate) mod postorder;
|
||||||
pub mod ssa;
|
pub(crate) mod ssa;
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod index;
|
mod index;
|
||||||
pub use index::{Block, Inst, InstRange, InstRangeIter};
|
pub use index::{Block, Inst, InstRange, InstRangeIter};
|
||||||
|
|
||||||
pub mod checker;
|
pub mod checker;
|
||||||
|
|||||||
Reference in New Issue
Block a user