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:
@@ -43,7 +43,7 @@ impl SubTest for TestLegalizer {
|
|||||||
comp_ctx.flowgraph();
|
comp_ctx.flowgraph();
|
||||||
comp_ctx
|
comp_ctx
|
||||||
.legalize(isa)
|
.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();
|
let mut text = String::new();
|
||||||
write!(&mut text, "{}", &comp_ctx.func.display(Some(isa)))
|
write!(&mut text, "{}", &comp_ctx.func.display(Some(isa)))
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ impl SubTest for TestLICM {
|
|||||||
comp_ctx.flowgraph();
|
comp_ctx.flowgraph();
|
||||||
comp_ctx
|
comp_ctx
|
||||||
.licm()
|
.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();
|
let mut text = String::new();
|
||||||
write!(&mut text, "{}", &comp_ctx.func)
|
write!(&mut text, "{}", &comp_ctx.func)
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ impl SubTest for TestRegalloc {
|
|||||||
// TODO: Should we have an option to skip legalization?
|
// TODO: Should we have an option to skip legalization?
|
||||||
comp_ctx
|
comp_ctx
|
||||||
.legalize(isa)
|
.legalize(isa)
|
||||||
.map_err(|e| pretty_error(&comp_ctx.func, e))?;
|
.map_err(|e| pretty_error(&comp_ctx.func, context.isa, e))?;
|
||||||
comp_ctx
|
comp_ctx
|
||||||
.regalloc(isa)
|
.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();
|
let mut text = String::new();
|
||||||
write!(&mut text, "{}", &comp_ctx.func.display(Some(isa)))
|
write!(&mut text, "{}", &comp_ctx.func.display(Some(isa)))
|
||||||
|
|||||||
@@ -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?
|
// Should we run the verifier before this test?
|
||||||
if !context.verified && test.needs_verifier() {
|
if !context.verified && test.needs_verifier() {
|
||||||
verify_function(&func, isa)
|
verify_function(&func, isa)
|
||||||
.map_err(|e| pretty_verifier_error(&func, e))?;
|
.map_err(|e| pretty_verifier_error(&func, isa, e))?;
|
||||||
context.verified = true;
|
context.verified = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ impl SubTest for TestSimpleGVN {
|
|||||||
comp_ctx.flowgraph();
|
comp_ctx.flowgraph();
|
||||||
comp_ctx
|
comp_ctx
|
||||||
.simple_gvn()
|
.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();
|
let mut text = String::new();
|
||||||
write!(&mut text, "{}", &comp_ctx.func)
|
write!(&mut text, "{}", &comp_ctx.func)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
use cretonne::ir::entities::AnyEntity;
|
use cretonne::ir::entities::AnyEntity;
|
||||||
use cretonne::{ir, verifier};
|
use cretonne::{ir, verifier};
|
||||||
use cretonne::result::CtonError;
|
use cretonne::result::CtonError;
|
||||||
|
use cretonne::isa::TargetIsa;
|
||||||
use std::fmt::Write;
|
use std::fmt::Write;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Result, Read};
|
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.
|
/// 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();
|
let mut msg = err.to_string();
|
||||||
match err.location {
|
match err.location {
|
||||||
AnyEntity::Inst(inst) => {
|
AnyEntity::Inst(inst) => {
|
||||||
@@ -42,14 +46,14 @@ pub fn pretty_verifier_error(func: &ir::Function, err: verifier::Error) -> Strin
|
|||||||
}
|
}
|
||||||
_ => msg.push('\n'),
|
_ => msg.push('\n'),
|
||||||
}
|
}
|
||||||
write!(msg, "{}", func).unwrap();
|
write!(msg, "{}", func.display(isa)).unwrap();
|
||||||
msg
|
msg
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Pretty-print a Cretonne error.
|
/// 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 {
|
if let CtonError::Verifier(e) = err {
|
||||||
pretty_verifier_error(func, e)
|
pretty_verifier_error(func, isa, e)
|
||||||
} else {
|
} else {
|
||||||
err.to_string()
|
err.to_string()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user