mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 14:55:26 +00:00
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.
This commit is contained in:
parent
b75b3b3afe
commit
feeaa4db3c
@ -107,26 +107,10 @@ pub trait FnAbiGccExt<'gcc, 'tcx> {
|
|||||||
impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'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>) {
|
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 mut on_stack_param_indices = FxHashSet::default();
|
||||||
let args_capacity: usize = self.args.iter().map(|arg|
|
|
||||||
if arg.pad.is_some() {
|
// This capacity calculation is approximate.
|
||||||
1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
} +
|
|
||||||
if let PassMode::Pair(_, _) = arg.mode {
|
|
||||||
2
|
|
||||||
} else {
|
|
||||||
1
|
|
||||||
}
|
|
||||||
).sum();
|
|
||||||
let mut argument_tys = Vec::with_capacity(
|
let mut argument_tys = Vec::with_capacity(
|
||||||
if let PassMode::Indirect { .. } = self.ret.mode {
|
self.args.len() + if let PassMode::Indirect { .. } = self.ret.mode { 1 } else { 0 }
|
||||||
1
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
0
|
|
||||||
} + args_capacity,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
let return_ty =
|
let return_ty =
|
||||||
|
@ -328,12 +328,9 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
|||||||
let args =
|
let args =
|
||||||
if self.c_variadic { &self.args[..self.fixed_count as usize] } else { &self.args };
|
if self.c_variadic { &self.args[..self.fixed_count as usize] } else { &self.args };
|
||||||
|
|
||||||
let args_capacity: usize = args.iter().map(|arg|
|
// This capacity calculation is approximate.
|
||||||
if arg.pad.is_some() { 1 } else { 0 } +
|
|
||||||
if let PassMode::Pair(_, _) = arg.mode { 2 } else { 1 }
|
|
||||||
).sum();
|
|
||||||
let mut llargument_tys = Vec::with_capacity(
|
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 {
|
let llreturn_ty = match &self.ret.mode {
|
||||||
|
Loading…
Reference in New Issue
Block a user