Add a liveness verifier.
The liveness verifier will check that the live ranges are consistent with the function. It runs as part of the register allocation pipeline when enable_verifier is set. The initial implementation checks the live ranges, but not the ISA-specific constraints and affinities.
This commit is contained in:
@@ -64,6 +64,27 @@ use std::fmt::{self, Display, Formatter};
|
||||
use std::result;
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
pub use self::liveness::verify_liveness;
|
||||
|
||||
// Create an `Err` variant of `Result<X>` from a location and `format!` arguments.
|
||||
macro_rules! err {
|
||||
( $loc:expr, $msg:expr ) => {
|
||||
Err(::verifier::Error {
|
||||
location: $loc.into(),
|
||||
message: String::from($msg),
|
||||
})
|
||||
};
|
||||
|
||||
( $loc:expr, $fmt:expr, $( $arg:expr ),+ ) => {
|
||||
Err(::verifier::Error {
|
||||
location: $loc.into(),
|
||||
message: format!( $fmt, $( $arg ),+ ),
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
mod liveness;
|
||||
|
||||
/// A verifier error.
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct Error {
|
||||
@@ -88,23 +109,6 @@ impl std_error::Error for Error {
|
||||
/// Verifier result.
|
||||
pub type Result = result::Result<(), Error>;
|
||||
|
||||
// Create an `Err` variant of `Result<X>` from a location and `format!` arguments.
|
||||
macro_rules! err {
|
||||
( $loc:expr, $msg:expr ) => {
|
||||
Err(Error {
|
||||
location: $loc.into(),
|
||||
message: String::from($msg),
|
||||
})
|
||||
};
|
||||
|
||||
( $loc:expr, $fmt:expr, $( $arg:expr ),+ ) => {
|
||||
Err(Error {
|
||||
location: $loc.into(),
|
||||
message: format!( $fmt, $( $arg ),+ ),
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
/// Verify `func`.
|
||||
pub fn verify_function(func: &Function) -> Result {
|
||||
Verifier::new(func).run()
|
||||
|
||||
Reference in New Issue
Block a user