about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNicholas Nethercote <n.nethercote@gmail.com>2022-08-26 10:37:51 +1000
committerAntoni Boucher <bouanto@zoho.com>2023-02-28 18:57:14 -0500
commit3c2d43265c1691647a9e2adc57c7239a4366a624 (patch)
tree27f9d6e9bf25bb9a3f374b0bb502cda372b05cd5
parenta283dedd44f5e426f01d24a447fbf4cb7d5dc41a (diff)
downloadrust-3c2d43265c1691647a9e2adc57c7239a4366a624.tar.gz
rust-3c2d43265c1691647a9e2adc57c7239a4366a624.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.
-rw-r--r--src/abi.rs22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/abi.rs b/src/abi.rs
index 7f313583c82..87b730d29cd 100644
--- a/src/abi.rs
+++ b/src/abi.rs
@@ -107,26 +107,10 @@ pub trait FnAbiGccExt<'gcc, 'tcx> {
 impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
     fn gcc_type(&self, cx: &CodegenCx<'gcc, 'tcx>) -> (Type<'gcc>, Vec<Type<'gcc>>, bool, FxHashSet<usize>) {
         let mut on_stack_param_indices = FxHashSet::default();
-        let args_capacity: usize = self.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 argument_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 return_ty =