about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorJosh Stone <jistone@redhat.com>2021-08-04 11:20:31 -0700
committerJosh Stone <jistone@redhat.com>2021-08-05 10:58:55 -0700
commit41f27d903a2f6e81fbd082235fbdaacc0d356d1e (patch)
treebefaf776cc7c5b0b6287d6156c89bbab51e5dcfb /compiler/rustc_codegen_llvm/src
parent183d79cc09ad81bc2dc7b47cb8880046201e52a2 (diff)
downloadrust-41f27d903a2f6e81fbd082235fbdaacc0d356d1e.tar.gz
rust-41f27d903a2f6e81fbd082235fbdaacc0d356d1e.zip
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.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/abi.rs12
-rw-r--r--compiler/rustc_codegen_llvm/src/declare.rs2
-rw-r--r--compiler/rustc_codegen_llvm/src/intrinsic.rs2
-rw-r--r--compiler/rustc_codegen_llvm/src/type_.rs3
4 files changed, 9 insertions, 10 deletions
diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs
index 0bd50ff1ad1..abf0ea8cc0a 100644
--- a/compiler/rustc_codegen_llvm/src/abi.rs
+++ b/compiler/rustc_codegen_llvm/src/abi.rs
@@ -344,7 +344,7 @@ impl ArgAbiMethods<'tcx> for Builder<'a, 'll, 'tcx> {
 }
 
 pub trait FnAbiLlvmExt<'tcx> {
-    fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>, decl: bool) -> &'ll Type;
+    fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
     fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type;
     fn llvm_cconv(&self) -> llvm::CallConv;
     fn apply_attrs_llfn(&self, cx: &CodegenCx<'ll, 'tcx>, llfn: &'ll Value);
@@ -352,10 +352,10 @@ pub trait FnAbiLlvmExt<'tcx> {
 }
 
 impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
-    fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>, decl: bool) -> &'ll Type {
-        // Ignore extra args when calling C variadic functions.
-        let args =
-            if decl && self.c_variadic { &self.args[..self.fixed_count] } else { &self.args };
+    fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
+        // Ignore "extra" args from the call site for C variadic functions.
+        // Only the "fixed" args are part of the LLVM function signature.
+        let args = if self.c_variadic { &self.args[..self.fixed_count] } else { &self.args };
 
         let args_capacity: usize = args.iter().map(|arg|
             if arg.pad.is_some() { 1 } else { 0 } +
@@ -414,7 +414,7 @@ impl<'tcx> FnAbiLlvmExt<'tcx> for FnAbi<'tcx, Ty<'tcx>> {
     fn ptr_to_llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
         unsafe {
             llvm::LLVMPointerType(
-                self.llvm_type(cx, false),
+                self.llvm_type(cx),
                 cx.data_layout().instruction_address_space.0 as c_uint,
             )
         }
diff --git a/compiler/rustc_codegen_llvm/src/declare.rs b/compiler/rustc_codegen_llvm/src/declare.rs
index 6b9ab55459e..8977fa085b9 100644
--- a/compiler/rustc_codegen_llvm/src/declare.rs
+++ b/compiler/rustc_codegen_llvm/src/declare.rs
@@ -90,7 +90,7 @@ impl CodegenCx<'ll, 'tcx> {
             name,
             fn_abi.llvm_cconv(),
             llvm::UnnamedAddr::Global,
-            fn_abi.llvm_type(self, false),
+            fn_abi.llvm_type(self),
         );
         fn_abi.apply_attrs_llfn(self, llfn);
         llfn
diff --git a/compiler/rustc_codegen_llvm/src/intrinsic.rs b/compiler/rustc_codegen_llvm/src/intrinsic.rs
index 631602ac864..ed484185865 100644
--- a/compiler/rustc_codegen_llvm/src/intrinsic.rs
+++ b/compiler/rustc_codegen_llvm/src/intrinsic.rs
@@ -712,7 +712,7 @@ fn gen_fn<'ll, 'tcx>(
     codegen: &mut dyn FnMut(Builder<'_, 'll, 'tcx>),
 ) -> (&'ll Type, &'ll Value) {
     let fn_abi = FnAbi::of_fn_ptr(cx, rust_fn_sig, &[]);
-    let llty = fn_abi.llvm_type(cx, false);
+    let llty = fn_abi.llvm_type(cx);
     let llfn = cx.declare_fn(name, &fn_abi);
     cx.set_frame_pointer_type(llfn);
     cx.apply_target_cpu_attr(llfn);
diff --git a/compiler/rustc_codegen_llvm/src/type_.rs b/compiler/rustc_codegen_llvm/src/type_.rs
index 18df24d9277..69787df5e07 100644
--- a/compiler/rustc_codegen_llvm/src/type_.rs
+++ b/compiler/rustc_codegen_llvm/src/type_.rs
@@ -276,8 +276,7 @@ impl LayoutTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> {
         ty.llvm_type(self)
     }
     fn fn_decl_backend_type(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> &'ll Type {
-        // This does not include extra args when calling C variadic functions.
-        fn_abi.llvm_type(self, true)
+        fn_abi.llvm_type(self)
     }
     fn fn_ptr_backend_type(&self, fn_abi: &FnAbi<'tcx, Ty<'tcx>>) -> &'ll Type {
         fn_abi.ptr_to_llvm_type(self)