* Verifier now accepts multiple errors (fixes #387).
This commit is contained in:
committed by
Dan Gohman
parent
3f582f7cbd
commit
dbc547091f
@@ -30,7 +30,7 @@ use simple_gvn::do_simple_gvn;
|
||||
use std::vec::Vec;
|
||||
use timing;
|
||||
use unreachable_code::eliminate_unreachable_code;
|
||||
use verifier::{verify_context, verify_locations, VerifierResult};
|
||||
use verifier::{verify_context, verify_locations, VerifierErrors, VerifierResult};
|
||||
|
||||
/// Persistent data structures and compilation pipeline.
|
||||
pub struct Context {
|
||||
@@ -177,31 +177,43 @@ impl Context {
|
||||
///
|
||||
/// Also check that the dominator tree and control flow graph are consistent with the function.
|
||||
pub fn verify<'a, FOI: Into<FlagsOrIsa<'a>>>(&self, fisa: FOI) -> VerifierResult<()> {
|
||||
verify_context(&self.func, &self.cfg, &self.domtree, fisa)
|
||||
let mut errors = VerifierErrors::default();
|
||||
let _ = verify_context(&self.func, &self.cfg, &self.domtree, fisa, &mut errors);
|
||||
|
||||
if errors.is_empty() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(errors)
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the verifier only if the `enable_verifier` setting is true.
|
||||
pub fn verify_if<'a, FOI: Into<FlagsOrIsa<'a>>>(&self, fisa: FOI) -> CodegenResult<()> {
|
||||
let fisa = fisa.into();
|
||||
if fisa.flags.enable_verifier() {
|
||||
self.verify(fisa).map_err(Into::into)
|
||||
} else {
|
||||
Ok(())
|
||||
self.verify(fisa)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Run the locations verifier on the function.
|
||||
pub fn verify_locations(&self, isa: &TargetIsa) -> VerifierResult<()> {
|
||||
verify_locations(isa, &self.func, None)
|
||||
let mut errors = VerifierErrors::default();
|
||||
let _ = verify_locations(isa, &self.func, None, &mut errors);
|
||||
|
||||
if errors.is_empty() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(errors)
|
||||
}
|
||||
}
|
||||
|
||||
/// Run the locations verifier only if the `enable_verifier` setting is true.
|
||||
pub fn verify_locations_if(&self, isa: &TargetIsa) -> CodegenResult<()> {
|
||||
if isa.flags().enable_verifier() {
|
||||
self.verify_locations(isa).map_err(Into::into)
|
||||
} else {
|
||||
Ok(())
|
||||
self.verify_locations(isa)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Perform dead-code elimination on the function.
|
||||
|
||||
Reference in New Issue
Block a user