Wasm32: Rust should not spill v128 function params into shadow stack
Rust Internals [Unofficial]
May 20, 2026
You are allowed to pass core::arch::wasm32::v128 around even when the v128 target feature is disabled. In that case we have to pass v128 values by-ref. To prevent ABI mismatches when one crate disables v128 (libcore has it disabled) while other crates have it enabled, we have to unconditionally pass v128 by-ref.
github.com/rust-lang/rust
compiler/rustc_target/src/callconv/mod.rs
1f8e04d34
819. BackendRepr::SimdVector { .. } => {
820. // This is a fun case! The gist of what this is doing is
821. // that we want callers and callees to always agree on the
822. // ABI of how they pass SIMD arguments. If we were to *not*
823. // make these arguments indirect then they'd be immediates
824. // in LLVM, which means that they'd used whatever the
825. // appropriate ABI is for the callee and the caller. That
826. // means, for example, if the caller doesn't have AVX
827. // enabled but the callee does, then passing an AVX argument
828. // across this boundary would cause corrupt data to show up.
829. //
830. // This problem is fixed by unconditionally passing SIMD
831. // arguments through memory between callers and callees
832. // which should get them all to agree on ABI regardless of
833. // target feature sets. Some more information about this
834. // issue can be found in #44367.
835. //
836. // We *could* do better in some cases, e.g. on x86_64 targets where SSE2 is
837. // required. However, it turns out that that makes LLVM worse at optimizing this
838. // code, so we pass things indirectly even there. See #139029 for more on that.
Dit bestand is afgekapt. origineel weergeven
It shouldn't matter too much in the general case though as vendor intrinsics are always inlined and you generally want to inline any simd helpers too.
Discussion in the ATmosphere