cranelift: Add wasm tests for duplicate loads (#5514)

* cranelift-filetests: Add the ability to test optimized CLIF in Wasm tests

* cranelift: Add Wasm tests for identical loads, back to back
This commit is contained in:
Nick Fitzgerald
2023-01-04 10:52:32 -08:00
committed by GitHub
parent 7c67378ab6
commit d1920f5a2d
4 changed files with 215 additions and 0 deletions

View File

@@ -61,6 +61,11 @@ pub fn run(path: &Path, wat: &str) -> Result<()> {
.map_err(|e| crate::pretty_anyhow_error(&e.func, e.inner))?;
writeln!(&mut actual, "function {}:", func.name).unwrap();
writeln!(&mut actual, "{}", code.disasm.as_ref().unwrap()).unwrap();
} else if config.optimize {
let mut ctx = cranelift_codegen::Context::for_function(func.clone());
ctx.optimize(isa)
.map_err(|e| crate::pretty_anyhow_error(&ctx.func, e))?;
writeln!(&mut actual, "{}", ctx.func.display()).unwrap();
} else {
writeln!(&mut actual, "{}", func.display()).unwrap();
}