Skip to content

Commit

Permalink
fix singlepass issue wasmerio#2347
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Jun 5, 2021
1 parent cae21af commit dc0dcd0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/compiler-singlepass/src/codegen_x64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,9 +330,9 @@ impl<'a> FuncGen<'a> {
let tmp1 = self.machine.acquire_temp_xmm().unwrap();
let tmp2 = self.machine.acquire_temp_xmm().unwrap();
let tmp3 = self.machine.acquire_temp_xmm().unwrap();
let tmpg1 = self.machine.acquire_temp_gpr().unwrap();

self.emit_relaxed_binop(Assembler::emit_mov, sz, input, Location::XMM(tmp1));
let tmpg1 = self.machine.acquire_temp_gpr().unwrap();

match sz {
Size::S32 => {
Expand Down
27 changes: 27 additions & 0 deletions tests/compilers/imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ use std::sync::{
Arc,
};
use wasmer::*;
#[cfg(feature = "singlepass")]
use wasmer_compiler_singlepass::Singlepass;
use wasmer_engine_universal::Universal;

fn get_module(store: &Store) -> Result<Module> {
let wat = r#"
Expand Down Expand Up @@ -432,3 +435,27 @@ fn instance_local_memory_lifetime(config: crate::Config) -> Result<()> {

Ok(())
}

#[cfg(feature = "singlepass")]
#[test]
fn test_singlepass_emit_bug() -> Result<()> {
// https://github.com/wasmerio/wasmer/issues/2347
let wat = r#"(module
(type (;0;) (func (param f64) (result i32)))
(func (;0;) (type 0) (param f64) (result i32)
unreachable)
(func (;1;) (type 0) (param f64) (result i32)
i32.const -16579585
f64.convert_i32_s
f64.ceil
f64.ceil
local.get 0
f64.copysign
unreachable))
"#;

let store = Store::new(&Universal::new(Singlepass::default()).engine());
let module = Module::new(&store, wat)?;

Ok(())
}

0 comments on commit dc0dcd0

Please sign in to comment.