about summary refs log tree commit diff
path: root/tests/codegen
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2025-01-15 08:39:35 +0000
committerGitHub <noreply@github.com>2025-01-15 08:39:35 +0000
commit5460fbe610cacae6de98a3dfc3ffe9573f0c9906 (patch)
tree96bea23fabeb42d05f67dbb77d59f152a7e9f18d /tests/codegen
parentd40f2f77bf372b0ce5fc16000c6ec1b95bd654c0 (diff)
parent0930bfe6d29a2c9b5b71219ff4c946b732d3f3c7 (diff)
downloadrust-5460fbe610cacae6de98a3dfc3ffe9573f0c9906.tar.gz
rust-5460fbe610cacae6de98a3dfc3ffe9573f0c9906.zip
Merge pull request #4139 from rust-lang/rustup-2025-01-15
Automatic Rustup
Diffstat (limited to 'tests/codegen')
-rw-r--r--tests/codegen/abi-win64-zst.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/codegen/abi-win64-zst.rs b/tests/codegen/abi-win64-zst.rs
new file mode 100644
index 00000000000..dd361898144
--- /dev/null
+++ b/tests/codegen/abi-win64-zst.rs
@@ -0,0 +1,52 @@
+//@ compile-flags: -Z merge-functions=disabled
+
+//@ revisions: windows-gnu
+//@[windows-gnu] compile-flags: --target x86_64-pc-windows-gnu
+//@[windows-gnu] needs-llvm-components: x86
+
+//@ revisions: windows-msvc
+//@[windows-msvc] compile-flags: --target x86_64-pc-windows-msvc
+//@[windows-msvc] needs-llvm-components: x86
+
+// Also test what happens when using a Windows ABI on Linux.
+//@ revisions: linux
+//@[linux] compile-flags: --target x86_64-unknown-linux-gnu
+//@[linux] needs-llvm-components: x86
+
+#![feature(no_core, lang_items, rustc_attrs, abi_vectorcall)]
+#![no_core]
+#![crate_type = "lib"]
+
+#[lang = "sized"]
+trait Sized {}
+
+// Make sure the argument is always passed when explicitly requesting a Windows ABI.
+// Our goal here is to match clang: <https://clang.godbolt.org/z/Wr4jMWq3P>.
+
+// CHECK: define win64cc void @pass_zst_win64(ptr {{[^,]*}})
+#[no_mangle]
+extern "win64" fn pass_zst_win64(_: ()) {}
+
+// CHECK: define x86_vectorcallcc void @pass_zst_vectorcall(ptr {{[^,]*}})
+#[no_mangle]
+extern "vectorcall" fn pass_zst_vectorcall(_: ()) {}
+
+// windows-gnu: define void @pass_zst_fastcall(ptr {{[^,]*}})
+// windows-msvc: define void @pass_zst_fastcall(ptr {{[^,]*}})
+#[no_mangle]
+#[cfg(windows)] // "fastcall" is not valid on 64bit Linux
+extern "fastcall" fn pass_zst_fastcall(_: ()) {}
+
+// The sysv64 ABI ignores ZST.
+
+// CHECK: define x86_64_sysvcc void @pass_zst_sysv64()
+#[no_mangle]
+extern "sysv64" fn pass_zst_sysv64(_: ()) {}
+
+// For `extern "C"` functions, ZST are ignored on Linux put passed on Windows.
+
+// linux: define void @pass_zst_c()
+// windows-msvc: define void @pass_zst_c(ptr {{[^,]*}})
+// windows-gnu: define void @pass_zst_c(ptr {{[^,]*}})
+#[no_mangle]
+extern "C" fn pass_zst_c(_: ()) {}