{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreih6p2srdpfcebv7enbgjsl23ip55qucplwrtsapepj6fou4vbqdxq",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mmbkmyw4bpt2"
},
"path": "/t/wasm32-rust-should-not-spill-v128-function-params-into-shadow-stack/24344#post_2",
"publishedAt": "2026-05-20T08:21:02.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"github.com/rust-lang/rust",
"compiler/rustc_target/src/callconv/mod.rs",
"1f8e04d34",
"origineel weergeven"
],
"textContent": "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.\n\ngithub.com/rust-lang/rust\n\n#### compiler/rustc_target/src/callconv/mod.rs\n\n1f8e04d34\n\n\n\n\n\n\n 819. BackendRepr::SimdVector { .. } => {\n\n\n 820. // This is a fun case! The gist of what this is doing is\n\n\n 821. // that we want callers and callees to always agree on the\n\n\n 822. // ABI of how they pass SIMD arguments. If we were to *not*\n\n\n 823. // make these arguments indirect then they'd be immediates\n\n\n 824. // in LLVM, which means that they'd used whatever the\n\n\n 825. // appropriate ABI is for the callee and the caller. That\n\n\n 826. // means, for example, if the caller doesn't have AVX\n\n\n 827. // enabled but the callee does, then passing an AVX argument\n\n\n 828. // across this boundary would cause corrupt data to show up.\n\n\n 829. //\n\n\n 830. // This problem is fixed by unconditionally passing SIMD\n\n\n 831. // arguments through memory between callers and callees\n\n\n 832. // which should get them all to agree on ABI regardless of\n\n\n 833. // target feature sets. Some more information about this\n\n\n 834. // issue can be found in #44367.\n\n\n 835. //\n\n\n 836. // We *could* do better in some cases, e.g. on x86_64 targets where SSE2 is\n\n\n 837. // required. However, it turns out that that makes LLVM worse at optimizing this\n\n\n 838. // code, so we pass things indirectly even there. See #139029 for more on that.\n\n\n\n\n\nDit bestand is afgekapt. origineel weergeven\n\nIt 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.",
"title": "Wasm32: Rust should not spill v128 function params into shadow stack"
}