Skip to content

Commit 41f27d9

Browse files
committed
Remove the decl arg from FnAbi::llvm_type
We can apply the `c_variadic` fix all the time, rather than trying to distinguish between declarations and any other use.
1 parent 183d79c commit 41f27d9

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

compiler/rustc_codegen_llvm/src/abi.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -344,18 +344,18 @@ impl ArgAbiMethods<'tcx> for Builder<'a, 'll, 'tcx> {
344344
}
345345

346346
pub trait FnAbiLlvmExt<'tcx> {
347-
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>, decl: bool) -> &'ll Type;
347+
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
348348
fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
349349
fn llvm_cconv(&self) -> llvm::CallConv;
350350
fn apply_attrs_llfn(&self, cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value);
351351
fn apply_attrs_callsite(&self, bx: &mut Builder<'a, 'll, 'tcx>, callsite: &'ll Value);
352352
}
353353

354354
impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
355-
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>, decl: bool) -> &'ll Type {
356-
// Ignore extra args when calling C variadic functions.
357-
let args =
358-
if decl && self.c_variadic { &self.args[..self.fixed_count] } else { &self.args };
355+
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
356+
// Ignore "extra" args from the call site for C variadic functions.
357+
// Only the "fixed" args are part of the LLVM function signature.
358+
let args = if self.c_variadic { &self.args[..self.fixed_count] } else { &self.args };
359359

360360
let args_capacity: usize = args.iter().map(|arg|
361361
if arg.pad.is_some() { 1 } else { 0 } +
@@ -414,7 +414,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
414414
fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
415415
unsafe {
416416
llvm::LLVMPointerType(
417-
self.llvm_type(cx, false),
417+
self.llvm_type(cx),
418418
cx.data_layout().instruction_address_space.0 as c_uint,
419419
)
420420
}

compiler/rustc_codegen_llvm/src/declare.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl CodegenCx<'ll, 'tcx> {
9090
name,
9191
fn_abi.llvm_cconv(),
9292
llvm::UnnamedAddr::Global,
93-
fn_abi.llvm_type(self, false),
93+
fn_abi.llvm_type(self),
9494
);
9595
fn_abi.apply_attrs_llfn(self, llfn);
9696
llfn

compiler/rustc_codegen_llvm/src/intrinsic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ fn gen_fn<'ll, 'tcx>(
712712
codegen: &mut dyn FnMut(Builder<'_, 'll, 'tcx>),
713713
) -> (&'ll Type, &'ll Value) {
714714
let fn_abi = FnAbi::of_fn_ptr(cx, rust_fn_sig, &[]);
715-
let llty = fn_abi.llvm_type(cx, false);
715+
let llty = fn_abi.llvm_type(cx);
716716
let llfn = cx.declare_fn(name, &fn_abi);
717717
cx.set_frame_pointer_type(llfn);
718718
cx.apply_target_cpu_attr(llfn);

compiler/rustc_codegen_llvm/src/type_.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,7 @@ impl LayoutTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
276276
ty.llvm_type(self)
277277
}
278278
fn fn_decl_backend_type(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> &'ll Type {
279-
// This does not include extra args when calling C variadic functions.
280-
fn_abi.llvm_type(self, true)
279+
fn_abi.llvm_type(self)
281280
}
282281
fn fn_ptr_backend_type(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> &'ll Type {
283282
fn_abi.ptr_to_llvm_type(self)

0 commit comments

Comments
 (0)