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:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,9 @@ pub struct TestConfig {
|
||||
#[serde(default)]
|
||||
pub compile: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub optimize: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub settings: Vec<String>,
|
||||
|
||||
@@ -30,6 +33,13 @@ pub struct TestConfig {
|
||||
|
||||
impl TestConfig {
|
||||
pub fn validate(&self) -> Result<()> {
|
||||
if self.compile || self.optimize {
|
||||
ensure!(
|
||||
!(self.compile && self.optimize),
|
||||
"The `compile` and `optimize` options are mutually exclusive."
|
||||
);
|
||||
}
|
||||
|
||||
for global in self.globals.values() {
|
||||
ensure!(
|
||||
global.vmctx || global.load.is_some(),
|
||||
|
||||
Reference in New Issue
Block a user