Include ISA-specific information in verifier errors.

When the test driver reports a verifier error, make sure to include the
TargetIsa when printing the failing function.
This commit is contained in:
Jakob Stoklund Olesen
2017-07-12 09:59:00 -07:00
parent 924c4649cc
commit e4da2e1f22
6 changed files with 14 additions and 10 deletions

View File

@@ -43,7 +43,7 @@ impl SubTest for TestLegalizer {
comp_ctx.flowgraph();
comp_ctx
.legalize(isa)
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
.map_err(|e| pretty_error(&comp_ctx.func, context.isa, e))?;
let mut text = String::new();
write!(&mut text, "{}", &comp_ctx.func.display(Some(isa)))

View File

@@ -41,7 +41,7 @@ impl SubTest for TestLICM {
comp_ctx.flowgraph();
comp_ctx
.licm()
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
.map_err(|e| pretty_error(&comp_ctx.func, context.isa, e))?;
let mut text = String::new();
write!(&mut text, "{}", &comp_ctx.func)

View File

@@ -48,10 +48,10 @@ impl SubTest for TestRegalloc {
// TODO: Should we have an option to skip legalization?
comp_ctx
.legalize(isa)
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
.map_err(|e| pretty_error(&comp_ctx.func, context.isa, e))?;
comp_ctx
.regalloc(isa)
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
.map_err(|e| pretty_error(&comp_ctx.func, context.isa, e))?;
let mut text = String::new();
write!(&mut text, "{}", &comp_ctx.func.display(Some(isa)))

View File

@@ -118,7 +118,7 @@ fn run_one_test<'a>(tuple: (&'a SubTest, &'a Flags, Option<&'a TargetIsa>),
// Should we run the verifier before this test?
if !context.verified && test.needs_verifier() {
verify_function(&func, isa)
.map_err(|e| pretty_verifier_error(&func, e))?;
.map_err(|e| pretty_verifier_error(&func, isa, e))?;
context.verified = true;
}

View File

@@ -41,7 +41,7 @@ impl SubTest for TestSimpleGVN {
comp_ctx.flowgraph();
comp_ctx
.simple_gvn()
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
.map_err(|e| pretty_error(&comp_ctx.func, context.isa, e))?;
let mut text = String::new();
write!(&mut text, "{}", &comp_ctx.func)

View File

@@ -3,6 +3,7 @@
use cretonne::ir::entities::AnyEntity;
use cretonne::{ir, verifier};
use cretonne::result::CtonError;
use cretonne::isa::TargetIsa;
use std::fmt::Write;
use std::fs::File;
use std::io::{Result, Read};
@@ -34,7 +35,10 @@ pub fn match_directive<'a>(comment: &'a str, directive: &str) -> Option<&'a str>
}
/// Pretty-print a verifier error.
pub fn pretty_verifier_error(func: &ir::Function, err: verifier::Error) -> String {
pub fn pretty_verifier_error(func: &ir::Function,
isa: Option<&TargetIsa>,
err: verifier::Error)
-> String {
let mut msg = err.to_string();
match err.location {
AnyEntity::Inst(inst) => {
@@ -42,14 +46,14 @@ pub fn pretty_verifier_error(func: &ir::Function, err: verifier::Error) -> Strin
}
_ => msg.push('\n'),
}
write!(msg, "{}", func).unwrap();
write!(msg, "{}", func.display(isa)).unwrap();
msg
}
/// Pretty-print a Cretonne error.
pub fn pretty_error(func: &ir::Function, err: CtonError) -> String {
pub fn pretty_error(func: &ir::Function, isa: Option<&TargetIsa>, err: CtonError) -> String {
if let CtonError::Verifier(e) = err {
pretty_verifier_error(func, e)
pretty_verifier_error(func, isa, e)
} else {
err.to_string()
}