llvm: add safety-check for Wasm memcpy

When lowering the `memcpy` instruction, LLVM will lower it to WebAssembly's
`memory.copy` instruction when the bulk-memory feature is enabled. This
instruction will trap when the destination or source pointer is out-of-bounds.
By Zig's semantics, it is valid to have an invalid pointer when the length is 0.
To prevent runtimes from trapping, we add a safety-check for slices to only
lower to a memcpy instruction when the length is larger than 0.
836f9fceabLuuk de Gram committed on 7/8/2023, 3:45:04 PMparent89396ff
1 file changedLine totals unavailable