about summary refs log tree commit diff
path: root/tests/codegen-llvm
diff options
context:
space:
mode:
authorThe Miri Cronjob Bot <miri@cron.bot>2025-09-14 05:00:30 +0000
committerThe Miri Cronjob Bot <miri@cron.bot>2025-09-14 05:00:30 +0000
commit603341a94f202098e13b57e57d64240e1d11d10a (patch)
treeb9b8ea12cc180e5285c143aa10ce9ed19a576d74 /tests/codegen-llvm
parent3a784d9d1f292707000cdfce9072c876480471e4 (diff)
parent9c423796bbbb989bac15524d78cdc6d46641e5da (diff)
Merge ref 'a015919e54c6' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh.

Upstream ref: a015919e54c60b1b2bec7a98dec478cfc4a48f4e
Filtered ref: 1867c5844dba22ac4d77d1ceb7d1624c14139c16
Upstream diff: https://github.com/rust-lang/rust/compare/4ba1cf9ade4c8e2fa10676a50ee34594eb161837...a015919e54c60b1b2bec7a98dec478cfc4a48f4e

This merge was created using https://github.com/rust-lang/josh-sync.
Diffstat (limited to 'tests/codegen-llvm')
-rw-r--r--tests/codegen-llvm/cffi/c-variadic-inline.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/codegen-llvm/cffi/c-variadic-inline.rs b/tests/codegen-llvm/cffi/c-variadic-inline.rs
new file mode 100644
index 00000000000..369b7e571ca
--- /dev/null
+++ b/tests/codegen-llvm/cffi/c-variadic-inline.rs
@@ -0,0 +1,47 @@
+//@ compile-flags: -C opt-level=3
+#![feature(c_variadic)]
+
+// Test that the inline attributes are accepted on C-variadic functions.
+//
+// Currently LLVM is unable to inline C-variadic functions, but that is valid because despite
+// the name even `#[inline(always)]` is just a hint.
+
+#[inline(always)]
+unsafe extern "C" fn inline_always(mut ap: ...) -> u32 {
+    ap.arg::<u32>()
+}
+
+#[inline]
+unsafe extern "C" fn inline(mut ap: ...) -> u32 {
+    ap.arg::<u32>()
+}
+
+#[inline(never)]
+unsafe extern "C" fn inline_never(mut ap: ...) -> u32 {
+    ap.arg::<u32>()
+}
+
+#[cold]
+unsafe extern "C" fn cold(mut ap: ...) -> u32 {
+    ap.arg::<u32>()
+}
+
+#[unsafe(no_mangle)]
+#[inline(never)]
+fn helper() {
+    // CHECK-LABEL: helper
+    // CHECK-LABEL: call c_variadic_inline::inline_always
+    // CHECK-LABEL: call c_variadic_inline::inline
+    // CHECK-LABEL: call c_variadic_inline::inline_never
+    // CHECK-LABEL: call c_variadic_inline::cold
+    unsafe {
+        inline_always(1);
+        inline(2);
+        inline_never(3);
+        cold(4);
+    }
+}
+
+fn main() {
+    helper()
+}