From b853e8a6194637751bffbcfdd5bb51c7bfecdff5 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 25 Aug 2022 19:18:01 +1000 Subject: [PATCH] Turn `ArgAbi::pad` into a `bool`. Because it's only ever set to `None` or `Some(Reg::i32())`. --- compiler/rustc_codegen_gcc/src/abi.rs | 4 ++-- compiler/rustc_codegen_llvm/src/abi.rs | 8 ++++---- compiler/rustc_codegen_ssa/src/mir/block.rs | 6 +++--- compiler/rustc_codegen_ssa/src/mir/mod.rs | 4 ++-- .../rustc_const_eval/src/interpret/terminator.rs | 2 +- compiler/rustc_target/src/abi/call/mips.rs | 2 +- compiler/rustc_target/src/abi/call/mod.rs | 12 ++++++------ compiler/rustc_target/src/abi/call/sparc.rs | 2 +- 8 files changed, 20 insertions(+), 20 deletions(-) diff --git a/compiler/rustc_codegen_gcc/src/abi.rs b/compiler/rustc_codegen_gcc/src/abi.rs index 87b730d29cd..3186b363e35 100644 --- a/compiler/rustc_codegen_gcc/src/abi.rs +++ b/compiler/rustc_codegen_gcc/src/abi.rs @@ -126,8 +126,8 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { for arg in self.args.iter() { // add padding - if let Some(ty) = arg.pad { - argument_tys.push(ty.gcc_type(cx)); + if arg.pad_i32 { + argument_tys.push(Reg::i32().gcc_type(cx)); } let arg_ty = match arg.mode { diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index a06b07c1149..168cf3d0b58 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -345,8 +345,8 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { for arg in args { // add padding - if let Some(ty) = arg.pad { - llargument_tys.push(ty.llvm_type(cx)); + if arg.pad_i32 { + llargument_tys.push(Reg::i32().llvm_type(cx)); } let llarg_ty = match &arg.mode { @@ -440,7 +440,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { _ => {} } for arg in self.args.iter() { - if arg.pad.is_some() { + if arg.pad_i32 { apply(&ArgAttributes::new()); } match &arg.mode { @@ -516,7 +516,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { } } for arg in self.args.iter() { - if arg.pad.is_some() { + if arg.pad_i32 { apply(bx.cx, &ArgAttributes::new()); } match &arg.mode { diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 187af47114f..5b3f41263e7 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -21,7 +21,7 @@ use rustc_middle::ty::{self, Instance, Ty, TypeVisitable}; use rustc_span::source_map::Span; use rustc_span::{sym, Symbol}; use rustc_symbol_mangling::typeid::typeid_for_fnabi; -use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode}; +use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode, Reg}; use rustc_target::abi::{self, HasDataLayout, WrappingRange}; use rustc_target::spec::abi::Abi; @@ -1159,8 +1159,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { arg: &ArgAbi<'tcx, Ty<'tcx>>, ) { // Fill padding with undef value, where applicable. - if let Some(ty) = arg.pad { - llargs.push(bx.const_undef(bx.reg_backend_type(&ty))) + if arg.pad_i32 { + llargs.push(bx.const_undef(bx.reg_backend_type(&Reg::i32()))) } if arg.is_ignore() { diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index 8ee375fa9e3..f13b658b2ff 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -283,7 +283,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( for i in 0..tupled_arg_tys.len() { let arg = &fx.fn_abi.args[idx]; idx += 1; - if arg.pad.is_some() { + if arg.pad_i32 { llarg_idx += 1; } let pr_field = place.project_field(bx, i); @@ -309,7 +309,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let arg = &fx.fn_abi.args[idx]; idx += 1; - if arg.pad.is_some() { + if arg.pad_i32 { llarg_idx += 1; } diff --git a/compiler/rustc_const_eval/src/interpret/terminator.rs b/compiler/rustc_const_eval/src/interpret/terminator.rs index 27bb828feac..2fcdf6ded98 100644 --- a/compiler/rustc_const_eval/src/interpret/terminator.rs +++ b/compiler/rustc_const_eval/src/interpret/terminator.rs @@ -216,7 +216,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { } }; // Padding must be fully equal. - let pad_compat = || caller_abi.pad == callee_abi.pad; + let pad_compat = || caller_abi.pad_i32 == callee_abi.pad_i32; // When comparing the PassMode, we have to be smart about comparing the attributes. let arg_attr_compat = |a1: &ArgAttributes, a2: &ArgAttributes| { // There's only one regular attribute that matters for the call ABI: InReg. diff --git a/compiler/rustc_target/src/abi/call/mips.rs b/compiler/rustc_target/src/abi/call/mips.rs index 83d8657af11..ff8f3236214 100644 --- a/compiler/rustc_target/src/abi/call/mips.rs +++ b/compiler/rustc_target/src/abi/call/mips.rs @@ -24,7 +24,7 @@ where if arg.layout.is_aggregate() { arg.cast_to(Uniform { unit: Reg::i32(), total: size }); if !offset.is_aligned(align) { - arg.pad_with(Reg::i32()); + arg.pad_with_i32(); } } else { arg.extend_integer_width_to(32); diff --git a/compiler/rustc_target/src/abi/call/mod.rs b/compiler/rustc_target/src/abi/call/mod.rs index bf30c24258e..33f533e68f0 100644 --- a/compiler/rustc_target/src/abi/call/mod.rs +++ b/compiler/rustc_target/src/abi/call/mod.rs @@ -465,7 +465,7 @@ pub struct ArgAbi<'a, Ty> { pub layout: TyAndLayout<'a, Ty>, /// Dummy argument, which is emitted before the real argument. - pub pad: Option, + pub pad_i32: bool, pub mode: PassMode, } @@ -486,7 +486,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, pad_i32: false, mode } } fn indirect_pass_mode(layout: &TyAndLayout<'a, Ty>) -> PassMode { @@ -551,8 +551,8 @@ impl<'a, Ty> ArgAbi<'a, Ty> { self.mode = PassMode::Cast(Box::new(target.into())); } - pub fn pad_with(&mut self, reg: Reg) { - self.pad = Some(reg); + pub fn pad_with_i32(&mut self) { + self.pad_i32 = true; } pub fn is_indirect(&self) -> bool { @@ -737,6 +737,6 @@ 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>, 72); - static_assert_size!(FnAbi<'_, usize>, 96); + static_assert_size!(ArgAbi<'_, usize>, 64); + static_assert_size!(FnAbi<'_, usize>, 88); } diff --git a/compiler/rustc_target/src/abi/call/sparc.rs b/compiler/rustc_target/src/abi/call/sparc.rs index 83d8657af11..ff8f3236214 100644 --- a/compiler/rustc_target/src/abi/call/sparc.rs +++ b/compiler/rustc_target/src/abi/call/sparc.rs @@ -24,7 +24,7 @@ where if arg.layout.is_aggregate() { arg.cast_to(Uniform { unit: Reg::i32(), total: size }); if !offset.is_aligned(align) { - arg.pad_with(Reg::i32()); + arg.pad_with_i32(); } } else { arg.extend_integer_width_to(32);