Enhance Verifier error reporting;

This commit is contained in:
Benjamin Bouvier
2018-07-27 17:55:26 +02:00
committed by Dan Gohman
parent 1b42105faa
commit 3a550d185f
4 changed files with 34 additions and 27 deletions

View File

@@ -18,6 +18,16 @@ pub fn pretty_verifier_error(
err: &VerifierError,
) -> String {
let mut w = String::new();
match err.location {
ir::entities::AnyEntity::Inst(_) => {}
_ => {
// Print the error, because the pretty_function_error below won't do it since it isn't
// tied to an instruction.
writeln!(w, "verifier error summary: {}\n", err.to_string()).unwrap();
}
}
decorate_function(
&mut |w, func, isa, inst, indent| pretty_function_error(w, func, isa, inst, indent, err),
&mut w,
@@ -37,31 +47,27 @@ fn pretty_function_error(
err: &VerifierError,
) -> fmt::Result {
match err.location {
ir::entities::AnyEntity::Inst(inst) => {
if inst == cur_inst {
writeln!(
w,
"{1:0$}{2}",
indent,
"",
func.dfg.display_inst(cur_inst, isa)
)?;
write!(w, "{1:0$}^", indent, "")?;
for _c in cur_inst.to_string().chars() {
write!(w, "~")?;
}
writeln!(w, "\n\nverifier {}\n", err.to_string())
} else {
write!(
w,
"{1:0$}{2}",
indent,
"",
func.dfg.display_inst(cur_inst, isa)
)
ir::entities::AnyEntity::Inst(inst) if inst == cur_inst => {
writeln!(
w,
"{1:0$}{2}",
indent,
"",
func.dfg.display_inst(cur_inst, isa)
)?;
write!(w, "{1:0$}^", indent, "")?;
for _c in cur_inst.to_string().chars() {
write!(w, "~")?;
}
writeln!(w, " verifier {}\n", err.to_string())
}
_ => writeln!(w),
_ => writeln!(
w,
"{1:0$}{2}",
indent,
"",
func.dfg.display_inst(cur_inst, isa)
),
}
}

View File

@@ -820,7 +820,8 @@ impl<'a> Verifier<'a> {
if i != variable_args.len() {
return err!(
inst,
"mismatched argument count, got {}, expected {}",
"mismatched argument count for `{}`: got {}, expected {}",
self.func.dfg.display_inst(inst, None),
variable_args.len(),
i
);