Skip to content

Commit ac12c69

Browse files
committed
remove custom va_end implementation in the LLVM backend
it should use the fallback body instead
1 parent ba9444c commit ac12c69

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
148148
return Ok(());
149149
}
150150

151+
// va_end uses the fallback body (a no-op).
151152
sym::va_start => bx.va_start(args[0].immediate()),
152-
sym::va_end => bx.va_end(args[0].immediate()),
153+
153154
sym::size_of_val => {
154155
let tp_ty = fn_args.type_at(0);
155156
let (_, meta) = args[0].val.pointer_parts();
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ add-minicore
2+
//@ compile-flags: -Copt-level=3
3+
#![feature(c_variadic)]
4+
#![crate_type = "lib"]
5+
6+
unsafe extern "C" {
7+
fn g(v: *mut u8);
8+
}
9+
10+
#[unsafe(no_mangle)]
11+
pub unsafe extern "C" fn f(mut args: ...) {
12+
// CHECK: call void @llvm.va_start
13+
unsafe { g(&raw mut args as *mut u8) }
14+
// We expect one call to the LLVM va_end from our desugaring of `...`. The `Drop` implementation
15+
// should only call the rust va_end intrinsic, which is a no-op.
16+
//
17+
// CHECK: call void @llvm.va_end
18+
// CHECK-NOT: call void @llvm.va_end
19+
}

0 commit comments

Comments
 (0)