about summary refs log tree commit diff
path: root/src/test/ui/simd
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2021-06-03 08:58:12 -0700
committerAlex Crichton <alex@alexcrichton.com>2021-06-03 09:55:45 -0700
commit55769a5ca98452967deb66dc1043a45fe0b2ddba (patch)
tree5c1174ab1bc802242b5fdb1b63af18d7531c70c1 /src/test/ui/simd
parent835150e70288535bc57bb624792229b9dc94991d (diff)
downloadrust-55769a5ca98452967deb66dc1043a45fe0b2ddba.tar.gz
rust-55769a5ca98452967deb66dc1043a45fe0b2ddba.zip
wasm: Make simd types passed via indirection again
This commit updates wasm target specs to use `simd_types_indirect: true`
again. Long ago this was added since wasm simd types were always
translated to `v128` under-the-hood in LLVM, meaning that it didn't
matter whether that target feature was enabled or not. Now, however,
`v128` is conditionally used in codegen depending on target features
enabled, meaning that it's possible to get linker errors about different
signatures in code that correctly uses simd types. The fix is the same
as for all other platforms, which is to pass the type indirectly.
Diffstat (limited to 'src/test/ui/simd')
-rw-r--r--src/test/ui/simd/wasm-simd-indirect.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/test/ui/simd/wasm-simd-indirect.rs b/src/test/ui/simd/wasm-simd-indirect.rs
new file mode 100644
index 00000000000..deac593df43
--- /dev/null
+++ b/src/test/ui/simd/wasm-simd-indirect.rs
@@ -0,0 +1,33 @@
+// build-pass
+
+#![cfg_attr(target_arch = "wasm32", feature(wasm_simd, wasm_target_feature))]
+
+#[cfg(target_arch = "wasm32")]
+fn main() {
+    unsafe {
+        a::api_with_simd_feature();
+    }
+}
+
+#[cfg(target_arch = "wasm32")]
+mod a {
+    use std::arch::wasm32::*;
+
+    #[target_feature(enable = "simd128")]
+    pub unsafe fn api_with_simd_feature() {
+        crate::b::api_takes_v128(u64x2(0, 1));
+    }
+}
+
+#[cfg(target_arch = "wasm32")]
+mod b {
+    use std::arch::wasm32::*;
+
+    #[inline(never)]
+    pub fn api_takes_v128(a: v128) -> v128 {
+        a
+    }
+}
+
+#[cfg(not(target_arch = "wasm32"))]
+fn main() {}