Fix error not reported if at least one other error expected. (#485)

* fix error not reported if at least one other error expected.

* Fixed unused extern crate error if wasm feature is not enabled.

* No longer reporting deref cycles multiple times.

* Fix filetest type_check.clif.

* Switched comparison order for perf.

* Fixed isa/riscv/verify-encoding.clif filetest.
This commit is contained in:
Grégoire Geis
2018-08-28 19:33:46 +02:00
committed by Dan Gohman
parent 9eee91fc12
commit 0e67255f52
5 changed files with 17 additions and 5 deletions

View File

@@ -7,7 +7,7 @@ function %RV32I(i32 link [%x1]) -> i32 link [%x1] {
ebb0(v9999: i32):
; iconst.i32 needs legalizing, so it should throw a
[R#0,-] v1 = iconst.i32 0xf0f0f0f0f0 ; error: Instruction failed to re-encode
return v9999
[Iret#19] return v9999
}
function %RV32I(i32 link [%x1]) -> i32 link [%x1] {
@@ -17,5 +17,5 @@ ebb0(v9999: i32):
v1 = iconst.i32 1
v2 = iconst.i32 2
[R#0,-] v3 = iadd v1, v2 ; error: encoding R#00 should be R#0c
return v9999
[Iret#19] return v9999
}

View File

@@ -82,6 +82,7 @@ function %jump_args() {
v0 = iconst.i16 10
v3 = iconst.i64 20
jump ebb1(v0, v3) ; error: arg 0 (v0) has type i16, expected i64
; error: arg 1 (v3) has type i64, expected i16
ebb1(v10: i64, v11: i16):
return
}
@@ -91,6 +92,7 @@ function %jump_args2() {
v0 = iconst.i16 10
v3 = iconst.i64 20
brz v0, ebb1(v0, v3) ; error: arg 0 (v0) has type i16, expected i64
; error: arg 1 (v3) has type i64, expected i16
jump ebb1(v3, v0)
ebb1(v10: i64, v11: i16):
return

View File

@@ -15,13 +15,13 @@ extern crate cfg_if;
extern crate capstone;
extern crate clap;
extern crate cranelift_codegen;
extern crate cranelift_entity;
extern crate cranelift_filetests;
extern crate cranelift_reader;
extern crate pretty_env_logger;
cfg_if! {
if #[cfg(feature = "wasm")] {
extern crate cranelift_entity;
extern crate cranelift_wasm;
extern crate term;
extern crate wabt;

View File

@@ -328,6 +328,7 @@ impl<'a> Verifier<'a> {
// - cycles in the global value declarations.
// - use of 'vmctx' when no special parameter declares it.
fn verify_global_values(&self, errors: &mut VerifierErrors) -> VerifierStepResult<()> {
let mut cycle_seen = false;
let mut seen = SparseSet::new();
'gvs: for gv in self.func.global_values.keys() {
@@ -337,7 +338,10 @@ impl<'a> Verifier<'a> {
let mut cur = gv;
while let ir::GlobalValueData::Deref { base, .. } = self.func.global_values[cur] {
if seen.insert(base).is_some() {
if !cycle_seen {
report!(errors, gv, "deref cycle: {}", DisplayList(seen.as_slice()));
cycle_seen = true; // ensures we don't report the cycle multiple times
}
continue 'gvs;
}
@@ -1511,6 +1515,7 @@ impl<'a> Verifier<'a> {
pub fn run(&self, errors: &mut VerifierErrors) -> VerifierStepResult<()> {
self.verify_global_values(errors)?;
self.typecheck_entry_block_params(errors)?;
for ebb in self.func.layout.ebbs() {
for inst in self.func.layout.ebb_insts(ebb) {
self.ebb_integrity(ebb, inst, errors)?;

View File

@@ -66,7 +66,7 @@ impl SubTest for TestVerifier {
for expect in expected {
let pos = errors
.iter()
.position(|err| err.message.contains(expect.1) && err.location == expect.0);
.position(|err| err.location == expect.0 && err.message.contains(expect.1));
match pos {
None => {
@@ -78,6 +78,11 @@ impl SubTest for TestVerifier {
}
}
// report remaining errors
for err in errors {
write!(msg, "unexpected error {}", err).unwrap();
}
if msg.is_empty() {
Ok(())
} else {