summary refs log tree commit diff
path: root/src/test/codegen/c-variadic-opt.rs
diff options
context:
space:
mode:
authorAndrei Homescu <ah@immunant.com>2019-03-25 14:28:03 -0700
committerAndrei Homescu <ah@immunant.com>2019-06-17 16:04:49 -0700
commitb9ea653aee231114acbe6d4b3c7b1d692772d060 (patch)
treeeceeeff8ba9582d6fb956358c1dc06eceadb2a29 /src/test/codegen/c-variadic-opt.rs
parent70456a6cbd67c0547d22997007afaaed0819767e (diff)
downloadrust-b9ea653aee231114acbe6d4b3c7b1d692772d060.tar.gz
rust-b9ea653aee231114acbe6d4b3c7b1d692772d060.zip
Expose `VaListImpl` as the Rust equivalent of `__va_list_tag` and implement Clone for it.
Diffstat (limited to 'src/test/codegen/c-variadic-opt.rs')
-rw-r--r--src/test/codegen/c-variadic-opt.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/test/codegen/c-variadic-opt.rs b/src/test/codegen/c-variadic-opt.rs
index 8594d309b0a..969dce80f58 100644
--- a/src/test/codegen/c-variadic-opt.rs
+++ b/src/test/codegen/c-variadic-opt.rs
@@ -10,10 +10,21 @@ extern "C" {
 }
 
 // Ensure that `va_start` and `va_end` are properly injected even
-// when the "spoofed" `VaList` is not used.
+// when the "spoofed" `VaListImpl` is not used.
 #[no_mangle]
 pub unsafe extern "C" fn c_variadic_no_use(fmt: *const i8, mut ap: ...) -> i32 {
     // CHECK: call void @llvm.va_start
-    vprintf(fmt, ap)
+    vprintf(fmt, ap.as_va_list())
+    // CHECK: call void @llvm.va_end
+}
+
+// Check that `VaListImpl::clone` gets inlined into a direct call to `llvm.va_copy`
+#[no_mangle]
+pub unsafe extern "C" fn c_variadic_clone(fmt: *const i8, mut ap: ...) -> i32 {
+    // CHECK: call void @llvm.va_start
+    let mut ap2 = ap.clone();
+    // CHECK: call void @llvm.va_copy
+    let res = vprintf(fmt, ap2.as_va_list());
+    res
     // CHECK: call void @llvm.va_end
 }