Auto merge of #100999 - nnethercote:shrink-FnAbi, r=bjorn3
Shrink `FnAbi` Because they can take up a lot of memory in debug and release builds. r? `@bjorn3`
This commit is contained in:
commit
332cc8fb75
35 changed files with 165 additions and 181 deletions
|
@ -77,7 +77,7 @@ where
|
|||
classify_ret(cx, &mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ where
|
|||
classify_ret(cx, &mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ where
|
|||
classify_ret(cx, &mut fn_abi.ret, vfp);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ pub fn compute_abi_info<Ty>(fty: &mut FnAbi<'_, Ty>) {
|
|||
classify_ret_ty(&mut fty.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fty.args {
|
||||
for arg in fty.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
|||
classify_ret(&mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
|||
classify_ret(&mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
|||
classify_ret(&mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -22,10 +22,8 @@ where
|
|||
let align = arg.layout.align.max(dl.i32_align).min(dl.i64_align).abi;
|
||||
|
||||
if arg.layout.is_aggregate() {
|
||||
arg.cast_to(Uniform { unit: Reg::i32(), total: size });
|
||||
if !offset.is_aligned(align) {
|
||||
arg.pad_with(Reg::i32());
|
||||
}
|
||||
let pad_i32 = !offset.is_aligned(align);
|
||||
arg.cast_to_and_pad_i32(Uniform { unit: Reg::i32(), total: size }, pad_i32);
|
||||
} else {
|
||||
arg.extend_integer_width_to(32);
|
||||
}
|
||||
|
@ -42,7 +40,7 @@ where
|
|||
classify_ret(cx, &mut fn_abi.ret, &mut offset);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ where
|
|||
classify_ret(cx, &mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ mod x86;
|
|||
mod x86_64;
|
||||
mod x86_win64;
|
||||
|
||||
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
|
||||
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
|
||||
pub enum PassMode {
|
||||
/// Ignore the argument.
|
||||
///
|
||||
|
@ -40,9 +40,10 @@ pub enum PassMode {
|
|||
///
|
||||
/// The argument has a layout abi of `ScalarPair`.
|
||||
Pair(ArgAttributes, ArgAttributes),
|
||||
/// Pass the argument after casting it, to either
|
||||
/// a single uniform or a pair of registers.
|
||||
Cast(CastTarget),
|
||||
/// Pass the argument after casting it, to either a single uniform or a
|
||||
/// pair of registers. The bool indicates if a `Reg::i32()` dummy argument
|
||||
/// is emitted before the real argument.
|
||||
Cast(Box<CastTarget>, bool),
|
||||
/// Pass the argument indirectly via a hidden pointer.
|
||||
/// The `extra_attrs` value, if any, is for the extra data (vtable or length)
|
||||
/// which indicates that it refers to an unsized rvalue.
|
||||
|
@ -463,10 +464,6 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
|
|||
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
|
||||
pub struct ArgAbi<'a, Ty> {
|
||||
pub layout: TyAndLayout<'a, Ty>,
|
||||
|
||||
/// Dummy argument, which is emitted before the real argument.
|
||||
pub pad: Option<Reg>,
|
||||
|
||||
pub mode: PassMode,
|
||||
}
|
||||
|
||||
|
@ -486,7 +483,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
|
|||
Abi::Vector { .. } => PassMode::Direct(ArgAttributes::new()),
|
||||
Abi::Aggregate { .. } => PassMode::Direct(ArgAttributes::new()),
|
||||
};
|
||||
ArgAbi { layout, pad: None, mode }
|
||||
ArgAbi { layout, mode }
|
||||
}
|
||||
|
||||
fn indirect_pass_mode(layout: &TyAndLayout<'a, Ty>) -> PassMode {
|
||||
|
@ -548,11 +545,11 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
|
|||
}
|
||||
|
||||
pub fn cast_to<T: Into<CastTarget>>(&mut self, target: T) {
|
||||
self.mode = PassMode::Cast(target.into());
|
||||
self.mode = PassMode::Cast(Box::new(target.into()), false);
|
||||
}
|
||||
|
||||
pub fn pad_with(&mut self, reg: Reg) {
|
||||
self.pad = Some(reg);
|
||||
pub fn cast_to_and_pad_i32<T: Into<CastTarget>>(&mut self, target: T, pad_i32: bool) {
|
||||
self.mode = PassMode::Cast(Box::new(target.into()), pad_i32);
|
||||
}
|
||||
|
||||
pub fn is_indirect(&self) -> bool {
|
||||
|
@ -614,7 +611,7 @@ pub enum Conv {
|
|||
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
|
||||
pub struct FnAbi<'a, Ty> {
|
||||
/// The LLVM types of each argument.
|
||||
pub args: Vec<ArgAbi<'a, Ty>>,
|
||||
pub args: Box<[ArgAbi<'a, Ty>]>,
|
||||
|
||||
/// LLVM return type.
|
||||
pub ret: ArgAbi<'a, Ty>,
|
||||
|
@ -625,7 +622,7 @@ pub struct FnAbi<'a, Ty> {
|
|||
///
|
||||
/// Should only be different from args.len() when c_variadic is true.
|
||||
/// This can be used to know whether an argument is variadic or not.
|
||||
pub fixed_count: usize,
|
||||
pub fixed_count: u32,
|
||||
|
||||
pub conv: Conv,
|
||||
|
||||
|
@ -730,3 +727,13 @@ impl<'a, Ty> FnAbi<'a, Ty> {
|
|||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
// Some types are used a lot. Make sure they don't unintentionally get bigger.
|
||||
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
|
||||
mod size_asserts {
|
||||
use super::*;
|
||||
use rustc_data_structures::static_assert_size;
|
||||
// These are in alphabetical order, which is easy to maintain.
|
||||
static_assert_size!(ArgAbi<'_, usize>, 56);
|
||||
static_assert_size!(FnAbi<'_, usize>, 80);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
|||
classify_ret(&mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
|||
classify_ret(&mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ where
|
|||
panic!("Kernels should not return anything other than () or !");
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
|||
classify_ret(&mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -132,7 +132,7 @@ where
|
|||
classify_ret(cx, &mut fn_abi.ret, abi);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -340,7 +340,7 @@ where
|
|||
arg,
|
||||
xlen,
|
||||
flen,
|
||||
i >= fn_abi.fixed_count,
|
||||
i >= fn_abi.fixed_count as usize,
|
||||
&mut avail_gprs,
|
||||
&mut avail_fprs,
|
||||
);
|
||||
|
|
|
@ -48,7 +48,7 @@ where
|
|||
classify_ret(&mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -22,10 +22,8 @@ where
|
|||
let align = arg.layout.align.max(dl.i32_align).min(dl.i64_align).abi;
|
||||
|
||||
if arg.layout.is_aggregate() {
|
||||
arg.cast_to(Uniform { unit: Reg::i32(), total: size });
|
||||
if !offset.is_aligned(align) {
|
||||
arg.pad_with(Reg::i32());
|
||||
}
|
||||
let pad_i32 = !offset.is_aligned(align);
|
||||
arg.cast_to_and_pad_i32(Uniform { unit: Reg::i32(), total: size }, pad_i32);
|
||||
} else {
|
||||
arg.extend_integer_width_to(32);
|
||||
}
|
||||
|
@ -42,7 +40,7 @@ where
|
|||
classify_ret(cx, &mut fn_abi.ret, &mut offset);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ where
|
|||
classify_arg(cx, &mut fn_abi.ret, Size { raw: 32 });
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ where
|
|||
classify_ret(cx, &mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ pub fn compute_wasm_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
|||
classify_ret(&mut fn_abi.ret);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ where
|
|||
|
||||
let mut free_regs = 2;
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
let attrs = match arg.mode {
|
||||
PassMode::Ignore
|
||||
| PassMode::Indirect { attrs: _, extra_attrs: None, on_stack: _ } => {
|
||||
|
@ -81,7 +81,7 @@ where
|
|||
PassMode::Direct(ref mut attrs) => attrs,
|
||||
PassMode::Pair(..)
|
||||
| PassMode::Indirect { attrs: _, extra_attrs: Some(_), on_stack: _ }
|
||||
| PassMode::Cast(_) => {
|
||||
| PassMode::Cast(..) => {
|
||||
unreachable!("x86 shouldn't be passing arguments by {:?}", arg.mode)
|
||||
}
|
||||
};
|
||||
|
|
|
@ -239,7 +239,7 @@ where
|
|||
x86_64_arg_or_ret(&mut fn_abi.ret, false);
|
||||
}
|
||||
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
|
|||
if !fn_abi.ret.is_ignore() {
|
||||
fixup(&mut fn_abi.ret);
|
||||
}
|
||||
for arg in &mut fn_abi.args {
|
||||
for arg in fn_abi.args.iter_mut() {
|
||||
if arg.is_ignore() {
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue