Improvements to error reporting (#470)

* Fixed error reporting.

* Fixed compile time error when wasm feature is disabled.

* Fixed valid instructions not being printed in print_function_error.

* Fixed errors print_function_error not writing valid instructions after end.

* Made multiple checks non-fatal.

* verify_global_values is no longer fatal.

* Slightly better formatting of errors in pretty_verifier_error.
This commit is contained in:
Grégoire Geis
2018-08-16 20:34:52 +02:00
committed by Dan Gohman
parent 304134d351
commit e2badb0ad6
3 changed files with 104 additions and 52 deletions

View File

@@ -25,17 +25,23 @@ pub fn pretty_verifier_error<'a>(
// TODO: Use drain_filter here when it gets stabilized
let mut i = 0;
let mut wrote_error = false;
while i != errors.len() {
if let ir::entities::AnyEntity::Inst(_) = errors[i].location {
i += 1;
} else {
let err = errors.remove(i);
writeln!(w, "Miscellaneous error: {}\n", err).unwrap()
} else {
i += 1;
writeln!(w, "verifier at {}", err).unwrap();
wrote_error = true;
}
}
if wrote_error {
w.push('\n');
}
decorate_function(
&mut PrettyVerifierError(func_w.unwrap_or(Box::new(PlainWriter)), &mut errors),
&mut w,
@@ -81,24 +87,41 @@ fn pretty_function_error(
) -> fmt::Result {
// TODO: Use drain_filter here when it gets stabilized
let mut i = 0;
let mut printed_instr = false;
while i != errors.len() {
match errors[i].location {
ir::entities::AnyEntity::Inst(inst) if inst == cur_inst => {
let err = errors.remove(i);
func_w.write_instruction(w, func, isa, cur_inst, indent)?;
if !printed_instr {
func_w.write_instruction(w, func, isa, cur_inst, indent)?;
printed_instr = true;
}
write!(w, "{1:0$}^", indent, "")?;
for _c in cur_inst.to_string().chars() {
write!(w, "~")?;
}
writeln!(w, " verifier {}\n", err.to_string())?;
writeln!(w, " verifier {}", err.to_string())?;
}
ir::entities::AnyEntity::Inst(_) => i += 1,
_ => unreachable!(),
}
}
if printed_instr {
w.write_char('\n')?;
} else {
writeln!(
w,
"{1:0$}{2}",
indent,
"",
func.dfg.display_inst(cur_inst, isa)
)?;
}
Ok(())
}