mirror of
https://github.com/rust-lang/rust.git
synced 2025-10-10 14:17:47 +00:00

This changes wasm simd intrisnics which deal with memory to match clang where they all are emitted with an alignment of 1. This is expected to not impact performance since wasm engines generally ignore alignment as it's just a hint. Otherwise this can increase safety slightly when used from Rust since if an unaligned pointer was previously passed in that could result in UB on the LLVM side. This means that the intrinsics are slighly more usable in more situations than before. It's expected that if higher alignment is desired then programs will not use these intrinsics but rather the component parts. For example instead of `v128_load` you'd just load the pointer itself (and loading from a pointer in Rust automatically assumes correct alignment). For `v128_load64_splat` you'd do a load followed by a splat operation, which LLVM should optimized into a `v128.load64_splat` instruction with the desired alignment. LLVM doesn't fully support some optimizations (such as optimizing `v128.load16_lane` from component parts) but that's expected to be a temporary issue. Additionally we don't have a way of configuring the alignment on operations that otherwise can't be decomposed into their portions (such as with `i64x2_load_extend_u32x2`), but we can ideally cross such a bridge when we get there if anyone ever needs the alignment configured there.