I have a risc-v processor that doesn't support misaligned memory accesses. I ahead-of-time compile a wasm program with Wamrc but when I run it I get a trap for a misaligned load. I know that WebAssembly allows unaligned memory accesses so this isn't surprising but I wonder if it is possible to adjust load/stores to check for alignment when generating the LLVM-IR during compilation?
In core/iwasm/common/wasm_runtime_common.h there are several macros for doing unaligned stores/loads : STORE_I64, STORE_U32, LOAD_I64, LOAD_I16, ... I imagine something similar to these: Whenever the Wasm code wants to make a load or store, Wamrc emits instructions similar to these macros.
Is this possible today, or would it be hard to implement?
I have a risc-v processor that doesn't support misaligned memory accesses. I ahead-of-time compile a wasm program with Wamrc but when I run it I get a trap for a misaligned load. I know that WebAssembly allows unaligned memory accesses so this isn't surprising but I wonder if it is possible to adjust load/stores to check for alignment when generating the LLVM-IR during compilation?
In
core/iwasm/common/wasm_runtime_common.hthere are several macros for doing unaligned stores/loads :STORE_I64,STORE_U32,LOAD_I64,LOAD_I16, ... I imagine something similar to these: Whenever the Wasm code wants to make a load or store, Wamrc emits instructions similar to these macros.Is this possible today, or would it be hard to implement?