candymate opened issue #8114:
Test Case
// main.rs use wasmtime::*; fn main() -> Result<()> { let mut config = Config::default(); config.strategy(Strategy::Cranelift); config.cranelift_opt_level(OptLevel::None); let engine1 = Engine::new(&config)?; let mut new_config = config.clone(); new_config.cranelift_opt_level(OptLevel::Speed); let engine2 = Engine::new(&new_config)?; let wat = r#" (module (type (;0;) (func (param i64 i64) (result i64))) (import "mem" "mem" (memory (;0;) 1)) (func (;0;) (type 0) (param i64 i64) (result i64) local.get 0 local.get 1 local.get 1 local.get 0 i64.gt_s select) (export "main" (func 0))) "#; let module1 = Module::new(&engine1, wat)?; let module2 = Module::new(&engine2, wat)?; let mut store1 = Store::new(&engine1, ()); let mut store2 = Store::new(&engine2, ()); let memory_ty = MemoryType::new(1, None); let memory1 = Memory::new(&mut store1, memory_ty.clone())?; let memory2 = Memory::new(&mut store2, memory_ty)?; let instance1 = Instance::new(&mut store1, &module1, &[memory1.into()])?; let instance2 = Instance::new(&mut store2, &module2, &[memory2.into()])?; let main1 = instance1.get_func(&mut store1, "main") .expect("`main` was not an exported function"); let main2 = instance2.get_func(&mut store2, "main") .expect("`main` was not an exported function"); let params = vec![ Val::I64(42), Val::I64(41), ]; let mut results1 = vec![Val::null()]; let mut results2 = vec![Val::null()]; println!("Opt level None: {:?}", main1.call( &mut store1, ¶ms, &mut results1 )); println!("{:?}", results1); println!("--------------"); println!("Opt level Speed: {:?}", main2.call( &mut store2, ¶ms, &mut results2 )); println!("{:?}", results2); Ok(()) }
[package] name = "wasmtime-wrapper" version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] wasmtime = "18.0.3"
Steps to reproduce
cargo run --release --target=riscv64gc-unknown-linux-gnu
QEMU run options I'm currently using is the following:
qemu-riscv64 -cpu rv64,v=true,vlen=128,vext_spec=v1.0,zba=true,zbb=true,zbs=true,zbc=true,zbkb=true,zcb=true,zicond=true -L /usr/riscv64-linux-gnu -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib -E WASMTIME_TEST_NO_HOG_MEMORY=1 target/riscv64gc-unknown-linux-gnu/release/wasmtime-wrapper
Expected Results
Both results from none and speed optimizations should show the same result 41
Opt level None: Ok(()) [I64(41)] -------------- Opt level Speed: Ok(()) [I64(41)]
Actual Results
Opt level None: Ok(()) [I64(41)] -------------- Opt level Speed: Ok(()) [I64(42)]
Versions and Environment
- wasmtime version: v18.0.3
- Operating system & architecture: Ubuntu 22.04.3 LTS, Arch: x86_64
- QEMU version:
qemu-riscv64 version 8.2.1 (v8.2.1)
Extra Info
- The test case is possibly related to
select - sgt
optimization - following rule- Does not work on other architectures (x86_64, aarch64, s390x)
afonso360 commented on issue #8114:
Thanks for the report! I'm going to look into this.
alexcrichton closed issue #8114:
Test Case
// main.rs use wasmtime::*; fn main() -> Result<()> { let mut config = Config::default(); config.strategy(Strategy::Cranelift); config.cranelift_opt_level(OptLevel::None); let engine1 = Engine::new(&config)?; let mut new_config = config.clone(); new_config.cranelift_opt_level(OptLevel::Speed); let engine2 = Engine::new(&new_config)?; let wat = r#" (module (type (;0;) (func (param i64 i64) (result i64))) (import "mem" "mem" (memory (;0;) 1)) (func (;0;) (type 0) (param i64 i64) (result i64) local.get 0 local.get 1 local.get 1 local.get 0 i64.gt_s select) (export "main" (func 0))) "#; let module1 = Module::new(&engine1, wat)?; let module2 = Module::new(&engine2, wat)?; let mut store1 = Store::new(&engine1, ()); let mut store2 = Store::new(&engine2, ()); let memory_ty = MemoryType::new(1, None); let memory1 = Memory::new(&mut store1, memory_ty.clone())?; let memory2 = Memory::new(&mut store2, memory_ty)?; let instance1 = Instance::new(&mut store1, &module1, &[memory1.into()])?; let instance2 = Instance::new(&mut store2, &module2, &[memory2.into()])?; let main1 = instance1.get_func(&mut store1, "main") .expect("`main` was not an exported function"); let main2 = instance2.get_func(&mut store2, "main") .expect("`main` was not an exported function"); let params = vec![ Val::I64(42), Val::I64(41), ]; let mut results1 = vec![Val::null()]; let mut results2 = vec![Val::null()]; println!("Opt level None: {:?}", main1.call( &mut store1, ¶ms, &mut results1 )); println!("{:?}", results1); println!("--------------"); println!("Opt level Speed: {:?}", main2.call( &mut store2, ¶ms, &mut results2 )); println!("{:?}", results2); Ok(()) }
[package] name = "wasmtime-wrapper" version = "0.1.0" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] wasmtime = "18.0.3"
Steps to reproduce
cargo run --release --target=riscv64gc-unknown-linux-gnu
QEMU run options I'm currently using is the following:
qemu-riscv64 -cpu rv64,v=true,vlen=128,vext_spec=v1.0,zba=true,zbb=true,zbs=true,zbc=true,zbkb=true,zcb=true,zicond=true -L /usr/riscv64-linux-gnu -E LD_LIBRARY_PATH=/usr/riscv64-linux-gnu/lib -E WASMTIME_TEST_NO_HOG_MEMORY=1 target/riscv64gc-unknown-linux-gnu/release/wasmtime-wrapper
Expected Results
Both results from none and speed optimizations should show the same result 41
Opt level None: Ok(()) [I64(41)] -------------- Opt level Speed: Ok(()) [I64(41)]
Actual Results
Opt level None: Ok(()) [I64(41)] -------------- Opt level Speed: Ok(()) [I64(42)]
Versions and Environment
- wasmtime version: v18.0.3
- Operating system & architecture: Ubuntu 22.04.3 LTS, Arch: x86_64
- QEMU version:
qemu-riscv64 version 8.2.1 (v8.2.1)
Extra Info
- The test case is possibly related to
select - sgt
optimization - following rule- Does not work on other architectures (x86_64, aarch64, s390x)
alexcrichton added the fuzz-bug label to Issue #8114.
alexcrichton added the cranelift:area:riscv64 label to Issue #8114.
Last updated: Dec 23 2024 at 12:05 UTC