1 // compile-flags: -C opt-level=3
4 #![feature(c_variadic)]
9 fn vprintf(fmt: *const i8, ap: VaList) -> i32;
12 // Ensure that `va_start` and `va_end` are properly injected even
13 // when the "spoofed" `VaListImpl` is not used.
15 pub unsafe extern "C" fn c_variadic_no_use(fmt: *const i8, mut ap: ...) -> i32 {
16 // CHECK: call void @llvm.va_start
17 vprintf(fmt, ap.as_va_list())
18 // CHECK: call void @llvm.va_end
21 // Check that `VaListImpl::clone` gets inlined into a direct call to `llvm.va_copy`
23 pub unsafe extern "C" fn c_variadic_clone(fmt: *const i8, mut ap: ...) -> i32 {
24 // CHECK: call void @llvm.va_start
25 let mut ap2 = ap.clone();
26 // CHECK: call void @llvm.va_copy
27 let res = vprintf(fmt, ap2.as_va_list());
29 // CHECK: call void @llvm.va_end