about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-08-26 10:37:51 +1000
committerNicholas Nethercote <n.nethercote@gmail.com>2022-08-26 10:45:45 +1000
commitfeeaa4db3cb990463871e35b16b3449023cb791d (patch)
treea9a8cd97aa0865b9745215abc473338f3e265355 /compiler/rustc_codegen_llvm/src
parentb75b3b3afecfb6638c7c75ad665f8f3091aab1ae (diff)
downloadrust-feeaa4db3cb990463871e35b16b3449023cb791d.tar.gz
rust-feeaa4db3cb990463871e35b16b3449023cb791d.zip
Simplify arg capacity calculations.
Currently they try to be very precise. But they are wrong, i.e. they
don't match what's happening in the loop below. This code isn't hot
enough for it to matter that much.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/abi.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs
index 2353362f83b..a06b07c1149 100644
--- a/compiler/rustc_codegen_llvm/src/abi.rs
+++ b/compiler/rustc_codegen_llvm/src/abi.rs
@@ -328,12 +328,9 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
         let args =
             if self.c_variadic { &self.args[..self.fixed_count as usize] } else { &self.args };
 
-        let args_capacity: usize = args.iter().map(|arg|
-            if arg.pad.is_some() { 1 } else { 0 } +
-            if let PassMode::Pair(_, _) = arg.mode { 2 } else { 1 }
-        ).sum();
+        // This capacity calculation is approximate.
         let mut llargument_tys = Vec::with_capacity(
-            if let PassMode::Indirect { .. } = self.ret.mode { 1 } else { 0 } + args_capacity,
+            self.args.len() + if let PassMode::Indirect { .. } = self.ret.mode { 1 } else { 0 },
         );
 
         let llreturn_ty = match &self.ret.mode {