diff --git a/cranelift/filetests/isa/riscv/verify-encoding.cton b/cranelift/filetests/isa/riscv/verify-encoding.cton
new file mode 100644
index 0000000000..73d28c842a
--- /dev/null
+++ b/cranelift/filetests/isa/riscv/verify-encoding.cton
@@ -0,0 +1,21 @@
+test verifier
+isa riscv
+
+function RV32I(i32 link [%x1]) -> i32 link [%x1] {
+ fn0 = function foo()
+
+ebb0(v9999: i32):
+ ; iconst.i32 needs legalizing, so it should throw a
+ [R#0,-] v1 = iconst.i32 1 ; error: Instruction failed to re-encode
+ return v9999
+}
+
+function RV32I(i32 link [%x1]) -> i32 link [%x1] {
+ fn0 = function foo()
+
+ebb0(v9999: i32):
+ v1 = iconst.i32 1
+ v2 = iconst.i32 2
+ [R#0,-] v3 = iadd v1, v2 ; error: Instruction re-encoding
+ return v9999
+}
diff --git a/cranelift/src/filetest/runone.rs b/cranelift/src/filetest/runone.rs
index bc16725d74..60231d22f4 100644
--- a/cranelift/src/filetest/runone.rs
+++ b/cranelift/src/filetest/runone.rs
@@ -116,7 +116,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).map_err(|e| pretty_verifier_error(&func, e))?;
+ verify_function(&func, isa).map_err(|e| pretty_verifier_error(&func, e))?;
context.verified = true;
}
diff --git a/cranelift/src/filetest/verifier.rs b/cranelift/src/filetest/verifier.rs
index 5812dc9db0..1dd5cc88b4 100644
--- a/cranelift/src/filetest/verifier.rs
+++ b/cranelift/src/filetest/verifier.rs
@@ -51,7 +51,7 @@ impl SubTest for TestVerifier {
}
}
- match verify_function(func) {
+ match verify_function(func, context.isa) {
Ok(_) => {
match expected {
None => Ok(()),
diff --git a/lib/cretonne/src/context.rs b/lib/cretonne/src/context.rs
index e4ba8a0667..d8b6af4d0b 100644
--- a/lib/cretonne/src/context.rs
+++ b/lib/cretonne/src/context.rs
@@ -53,8 +53,8 @@ impl Context {
///
/// The `TargetIsa` argument is currently unused, but the verifier will soon be able to also
/// check ISA-dependent constraints.
- pub fn verify<'a, ISA: Into