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:
Jakob Stoklund Olesen
2017-04-21 13:35:20 -07:00
parent 225ed39fbd
commit 85f277a2fb
6 changed files with 220 additions and 23 deletions

View File

@@ -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()