Expose ssa verification as a regalloc2 option (#102)
Adds the validate_ssa flag to the RegallocOptions struct, enabling ssa validation of inputs before register allocation takes place.
This commit is contained in:
@@ -11,5 +11,6 @@ fuzz_target!(|func: Func| {
|
||||
let _ = env_logger::try_init();
|
||||
log::trace!("func:\n{:?}", func);
|
||||
let env = regalloc2::fuzzing::func::machine_env();
|
||||
let _out = regalloc2::fuzzing::ion::run(&func, &env, false).expect("regalloc did not succeed");
|
||||
let _out =
|
||||
regalloc2::fuzzing::ion::run(&func, &env, false, false).expect("regalloc did not succeed");
|
||||
});
|
||||
|
||||
@@ -40,7 +40,8 @@ fuzz_target!(|testcase: TestCase| {
|
||||
let _ = env_logger::try_init();
|
||||
log::trace!("func:\n{:?}", func);
|
||||
let env = regalloc2::fuzzing::func::machine_env();
|
||||
let out = regalloc2::fuzzing::ion::run(&func, &env, true).expect("regalloc did not succeed");
|
||||
let out =
|
||||
regalloc2::fuzzing::ion::run(&func, &env, true, false).expect("regalloc did not succeed");
|
||||
|
||||
let mut checker = Checker::new(&func, &env);
|
||||
checker.prepare(&out);
|
||||
|
||||
@@ -8,7 +8,7 @@ use regalloc2::fuzzing::arbitrary::{Arbitrary, Result, Unstructured};
|
||||
use regalloc2::fuzzing::cfg::CFGInfo;
|
||||
use regalloc2::fuzzing::func::{Func, Options};
|
||||
use regalloc2::fuzzing::fuzz_target;
|
||||
use regalloc2::fuzzing::ssa::validate_ssa;
|
||||
use regalloc2::ssa::validate_ssa;
|
||||
|
||||
#[derive(Debug)]
|
||||
struct TestCase {
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
//! Utilities for fuzzing.
|
||||
|
||||
pub mod func;
|
||||
pub mod ssa;
|
||||
|
||||
// Re-exports for fuzz targets.
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
//! its design.
|
||||
|
||||
use crate::cfg::CFGInfo;
|
||||
use crate::ssa::validate_ssa;
|
||||
use crate::{Function, MachineEnv, Output, PReg, ProgPoint, RegAllocError, RegClass};
|
||||
use std::collections::HashMap;
|
||||
|
||||
@@ -120,9 +121,14 @@ pub fn run<F: Function>(
|
||||
func: &F,
|
||||
mach_env: &MachineEnv,
|
||||
enable_annotations: bool,
|
||||
enable_ssa_checker: bool,
|
||||
) -> Result<Output, RegAllocError> {
|
||||
let cfginfo = CFGInfo::new(func)?;
|
||||
|
||||
if enable_ssa_checker {
|
||||
validate_ssa(func, &cfginfo)?;
|
||||
}
|
||||
|
||||
let mut env = Env::new(func, mach_env, cfginfo, enable_annotations);
|
||||
env.init()?;
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ pub mod indexset;
|
||||
pub(crate) mod ion;
|
||||
pub(crate) mod moves;
|
||||
pub(crate) mod postorder;
|
||||
pub mod ssa;
|
||||
|
||||
#[macro_use]
|
||||
mod index;
|
||||
@@ -1477,7 +1478,7 @@ pub fn run<F: Function>(
|
||||
env: &MachineEnv,
|
||||
options: &RegallocOptions,
|
||||
) -> Result<Output, RegAllocError> {
|
||||
ion::run(func, env, options.verbose_log)
|
||||
ion::run(func, env, options.verbose_log, options.validate_ssa)
|
||||
}
|
||||
|
||||
/// Options for allocation.
|
||||
@@ -1485,4 +1486,7 @@ pub fn run<F: Function>(
|
||||
pub struct RegallocOptions {
|
||||
/// Add extra verbosity to debug logs.
|
||||
pub verbose_log: bool,
|
||||
|
||||
/// Run the SSA validator before allocating registers.
|
||||
pub validate_ssa: bool,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user