Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 332cc8f

Browse files
committedAug 27, 2022
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`
2 parents 3b3f3b7 + f974617 commit 332cc8f

File tree

35 files changed

+165
-181
lines changed

35 files changed

+165
-181
lines changed
 

‎compiler/rustc_codegen_cranelift/src/abi/comments.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub(super) fn add_arg_comment<'tcx>(
2424
local: Option<mir::Local>,
2525
local_field: Option<usize>,
2626
params: &[Value],
27-
arg_abi_mode: PassMode,
27+
arg_abi_mode: &PassMode,
2828
arg_layout: TyAndLayout<'tcx>,
2929
) {
3030
if !fx.clif_comments.enabled() {

‎compiler/rustc_codegen_cranelift/src/abi/pass_mode.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn apply_arg_attrs_to_abi_param(mut param: AbiParam, arg_attrs: ArgAttributes) -
3838
param
3939
}
4040

41-
fn cast_target_to_abi_params(cast: CastTarget) -> SmallVec<[AbiParam; 2]> {
41+
fn cast_target_to_abi_params(cast: &CastTarget) -> SmallVec<[AbiParam; 2]> {
4242
let (rest_count, rem_bytes) = if cast.rest.unit.size.bytes() == 0 {
4343
(0, 0)
4444
} else {
@@ -100,7 +100,10 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
100100
}
101101
_ => unreachable!("{:?}", self.layout.abi),
102102
},
103-
PassMode::Cast(cast) => cast_target_to_abi_params(cast),
103+
PassMode::Cast(ref cast, pad_i32) => {
104+
assert!(!pad_i32, "padding support not yet implemented");
105+
cast_target_to_abi_params(cast)
106+
}
104107
PassMode::Indirect { attrs, extra_attrs: None, on_stack } => {
105108
if on_stack {
106109
// Abi requires aligning struct size to pointer size
@@ -145,7 +148,9 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
145148
}
146149
_ => unreachable!("{:?}", self.layout.abi),
147150
},
148-
PassMode::Cast(cast) => (None, cast_target_to_abi_params(cast).into_iter().collect()),
151+
PassMode::Cast(ref cast, _) => {
152+
(None, cast_target_to_abi_params(cast).into_iter().collect())
153+
}
149154
PassMode::Indirect { attrs: _, extra_attrs: None, on_stack } => {
150155
assert!(!on_stack);
151156
(Some(AbiParam::special(pointer_ty(tcx), ArgumentPurpose::StructReturn)), vec![])
@@ -160,7 +165,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
160165
pub(super) fn to_casted_value<'tcx>(
161166
fx: &mut FunctionCx<'_, '_, 'tcx>,
162167
arg: CValue<'tcx>,
163-
cast: CastTarget,
168+
cast: &CastTarget,
164169
) -> SmallVec<[Value; 2]> {
165170
let (ptr, meta) = arg.force_stack(fx);
166171
assert!(meta.is_none());
@@ -179,7 +184,7 @@ pub(super) fn from_casted_value<'tcx>(
179184
fx: &mut FunctionCx<'_, '_, 'tcx>,
180185
block_params: &[Value],
181186
layout: TyAndLayout<'tcx>,
182-
cast: CastTarget,
187+
cast: &CastTarget,
183188
) -> CValue<'tcx> {
184189
let abi_params = cast_target_to_abi_params(cast);
185190
let abi_param_size: u32 = abi_params.iter().map(|param| param.value_type.bytes()).sum();
@@ -224,7 +229,7 @@ pub(super) fn adjust_arg_for_abi<'tcx>(
224229
let (a, b) = arg.load_scalar_pair(fx);
225230
smallvec![a, b]
226231
}
227-
PassMode::Cast(cast) => to_casted_value(fx, arg, cast),
232+
PassMode::Cast(ref cast, _) => to_casted_value(fx, arg, cast),
228233
PassMode::Indirect { .. } => {
229234
if is_owned {
230235
match arg.force_stack(fx) {
@@ -268,7 +273,7 @@ pub(super) fn cvalue_for_param<'tcx>(
268273
local,
269274
local_field,
270275
&block_params,
271-
arg_abi.mode,
276+
&arg_abi.mode,
272277
arg_abi.layout,
273278
);
274279

@@ -282,7 +287,9 @@ pub(super) fn cvalue_for_param<'tcx>(
282287
assert_eq!(block_params.len(), 2, "{:?}", block_params);
283288
Some(CValue::by_val_pair(block_params[0], block_params[1], arg_abi.layout))
284289
}
285-
PassMode::Cast(cast) => Some(from_casted_value(fx, &block_params, arg_abi.layout, cast)),
290+
PassMode::Cast(ref cast, _) => {
291+
Some(from_casted_value(fx, &block_params, arg_abi.layout, cast))
292+
}
286293
PassMode::Indirect { attrs: _, extra_attrs: None, on_stack: _ } => {
287294
assert_eq!(block_params.len(), 1, "{:?}", block_params);
288295
Some(CValue::by_ref(Pointer::new(block_params[0]), arg_abi.layout))

‎compiler/rustc_codegen_cranelift/src/abi/returning.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(super) fn codegen_return_param<'tcx>(
1313
block_params_iter: &mut impl Iterator<Item = Value>,
1414
) -> CPlace<'tcx> {
1515
let (ret_place, ret_param): (_, SmallVec<[_; 2]>) = match fx.fn_abi.as_ref().unwrap().ret.mode {
16-
PassMode::Ignore | PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast(_) => {
16+
PassMode::Ignore | PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast(..) => {
1717
let is_ssa = ssa_analyzed[RETURN_PLACE] == crate::analyze::SsaKind::Ssa;
1818
(
1919
super::make_local_place(
@@ -44,7 +44,7 @@ pub(super) fn codegen_return_param<'tcx>(
4444
Some(RETURN_PLACE),
4545
None,
4646
&ret_param,
47-
fx.fn_abi.as_ref().unwrap().ret.mode,
47+
&fx.fn_abi.as_ref().unwrap().ret.mode,
4848
fx.fn_abi.as_ref().unwrap().ret.layout,
4949
);
5050

@@ -75,7 +75,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
7575
PassMode::Indirect { attrs: _, extra_attrs: Some(_), on_stack: _ } => {
7676
unreachable!("unsized return value")
7777
}
78-
PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast(_) => (None, None),
78+
PassMode::Direct(_) | PassMode::Pair(_, _) | PassMode::Cast(..) => (None, None),
7979
};
8080

8181
let call_inst = f(fx, return_ptr);
@@ -92,7 +92,7 @@ pub(super) fn codegen_with_call_return_arg<'tcx>(
9292
ret_place
9393
.write_cvalue(fx, CValue::by_val_pair(ret_val_a, ret_val_b, ret_arg_abi.layout));
9494
}
95-
PassMode::Cast(cast) => {
95+
PassMode::Cast(ref cast, _) => {
9696
let results =
9797
fx.bcx.inst_results(call_inst).iter().copied().collect::<SmallVec<[Value; 2]>>();
9898
let result =
@@ -131,7 +131,7 @@ pub(crate) fn codegen_return(fx: &mut FunctionCx<'_, '_, '_>) {
131131
let (ret_val_a, ret_val_b) = place.to_cvalue(fx).load_scalar_pair(fx);
132132
fx.bcx.ins().return_(&[ret_val_a, ret_val_b]);
133133
}
134-
PassMode::Cast(cast) => {
134+
PassMode::Cast(ref cast, _) => {
135135
let place = fx.get_local_place(RETURN_PLACE);
136136
let ret_val = place.to_cvalue(fx);
137137
let ret_vals = super::pass_mode::to_casted_value(fx, ret_val, cast);

‎compiler/rustc_codegen_gcc/src/abi.rs

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -107,45 +107,24 @@ pub trait FnAbiGccExt<'gcc, 'tcx> {
107107
impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
108108
fn gcc_type(&self, cx: &CodegenCx<'gcc, 'tcx>) -> (Type<'gcc>, Vec<Type<'gcc>>, bool, FxHashSet<usize>) {
109109
let mut on_stack_param_indices = FxHashSet::default();
110-
let args_capacity: usize = self.args.iter().map(|arg|
111-
if arg.pad.is_some() {
112-
1
113-
}
114-
else {
115-
0
116-
} +
117-
if let PassMode::Pair(_, _) = arg.mode {
118-
2
119-
} else {
120-
1
121-
}
122-
).sum();
110+
111+
// This capacity calculation is approximate.
123112
let mut argument_tys = Vec::with_capacity(
124-
if let PassMode::Indirect { .. } = self.ret.mode {
125-
1
126-
}
127-
else {
128-
0
129-
} + args_capacity,
113+
self.args.len() + if let PassMode::Indirect { .. } = self.ret.mode { 1 } else { 0 }
130114
);
131115

132116
let return_ty =
133117
match self.ret.mode {
134118
PassMode::Ignore => cx.type_void(),
135119
PassMode::Direct(_) | PassMode::Pair(..) => self.ret.layout.immediate_gcc_type(cx),
136-
PassMode::Cast(cast) => cast.gcc_type(cx),
120+
PassMode::Cast(ref cast, _) => cast.gcc_type(cx),
137121
PassMode::Indirect { .. } => {
138122
argument_tys.push(cx.type_ptr_to(self.ret.memory_ty(cx)));
139123
cx.type_void()
140124
}
141125
};
142126

143-
for arg in &self.args {
144-
// add padding
145-
if let Some(ty) = arg.pad {
146-
argument_tys.push(ty.gcc_type(cx));
147-
}
148-
127+
for arg in self.args.iter() {
149128
let arg_ty = match arg.mode {
150129
PassMode::Ignore => continue,
151130
PassMode::Direct(_) => arg.layout.immediate_gcc_type(cx),
@@ -157,7 +136,13 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
157136
PassMode::Indirect { extra_attrs: Some(_), .. } => {
158137
unimplemented!();
159138
}
160-
PassMode::Cast(cast) => cast.gcc_type(cx),
139+
PassMode::Cast(ref cast, pad_i32) => {
140+
// add padding
141+
if pad_i32 {
142+
argument_tys.push(Reg::i32().gcc_type(cx));
143+
}
144+
cast.gcc_type(cx)
145+
}
161146
PassMode::Indirect { extra_attrs: None, on_stack: true, .. } => {
162147
on_stack_param_indices.insert(argument_tys.len());
163148
arg.memory_ty(cx)

‎compiler/rustc_codegen_gcc/src/intrinsic/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
130130
sym::volatile_load | sym::unaligned_volatile_load => {
131131
let tp_ty = substs.type_at(0);
132132
let mut ptr = args[0].immediate();
133-
if let PassMode::Cast(ty) = fn_abi.ret.mode {
133+
if let PassMode::Cast(ty, _) = &fn_abi.ret.mode {
134134
ptr = self.pointercast(ptr, self.type_ptr_to(ty.gcc_type(self)));
135135
}
136136
let load = self.volatile_load(ptr.get_type(), ptr);
@@ -320,7 +320,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
320320
};
321321

322322
if !fn_abi.ret.is_ignore() {
323-
if let PassMode::Cast(ty) = fn_abi.ret.mode {
323+
if let PassMode::Cast(ty, _) = &fn_abi.ret.mode {
324324
let ptr_llty = self.type_ptr_to(ty.gcc_type(self));
325325
let ptr = self.pointercast(result.llval, ptr_llty);
326326
self.store(llval, ptr, result.align);
@@ -416,7 +416,7 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
416416
else if self.is_unsized_indirect() {
417417
bug!("unsized `ArgAbi` must be handled through `store_fn_arg`");
418418
}
419-
else if let PassMode::Cast(cast) = self.mode {
419+
else if let PassMode::Cast(ref cast, _) = self.mode {
420420
// FIXME(eddyb): Figure out when the simpler Store is safe, clang
421421
// uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}.
422422
let can_store_through_cast_ptr = false;
@@ -481,7 +481,7 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
481481
PassMode::Indirect { extra_attrs: Some(_), .. } => {
482482
OperandValue::Ref(next(), Some(next()), self.layout.align.abi).store(bx, dst);
483483
},
484-
PassMode::Direct(_) | PassMode::Indirect { extra_attrs: None, .. } | PassMode::Cast(_) => {
484+
PassMode::Direct(_) | PassMode::Indirect { extra_attrs: None, .. } | PassMode::Cast(..) => {
485485
let next_arg = next();
486486
self.store(bx, next_arg, dst);
487487
},

‎compiler/rustc_codegen_llvm/src/abi.rs

Lines changed: 46 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
213213
OperandValue::Ref(val, None, self.layout.align.abi).store(bx, dst)
214214
} else if self.is_unsized_indirect() {
215215
bug!("unsized `ArgAbi` must be handled through `store_fn_arg`");
216-
} else if let PassMode::Cast(cast) = self.mode {
216+
} else if let PassMode::Cast(cast, _) = &self.mode {
217217
// FIXME(eddyb): Figure out when the simpler Store is safe, clang
218218
// uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}.
219219
let can_store_through_cast_ptr = false;
@@ -283,7 +283,7 @@ impl<'ll, 'tcx> ArgAbiExt<'ll, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
283283
}
284284
PassMode::Direct(_)
285285
| PassMode::Indirect { attrs: _, extra_attrs: None, on_stack: _ }
286-
| PassMode::Cast(_) => {
286+
| PassMode::Cast(..) => {
287287
let next_arg = next();
288288
self.store(bx, next_arg, dst);
289289
}
@@ -325,33 +325,26 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
325325
fn llvm_type(&self, cx: &CodegenCx<'ll, 'tcx>) -> &'ll Type {
326326
// Ignore "extra" args from the call site for C variadic functions.
327327
// Only the "fixed" args are part of the LLVM function signature.
328-
let args = if self.c_variadic { &self.args[..self.fixed_count] } else { &self.args };
328+
let args =
329+
if self.c_variadic { &self.args[..self.fixed_count as usize] } else { &self.args };
329330

330-
let args_capacity: usize = args.iter().map(|arg|
331-
if arg.pad.is_some() { 1 } else { 0 } +
332-
if let PassMode::Pair(_, _) = arg.mode { 2 } else { 1 }
333-
).sum();
331+
// This capacity calculation is approximate.
334332
let mut llargument_tys = Vec::with_capacity(
335-
if let PassMode::Indirect { .. } = self.ret.mode { 1 } else { 0 } + args_capacity,
333+
self.args.len() + if let PassMode::Indirect { .. } = self.ret.mode { 1 } else { 0 },
336334
);
337335

338-
let llreturn_ty = match self.ret.mode {
336+
let llreturn_ty = match &self.ret.mode {
339337
PassMode::Ignore => cx.type_void(),
340338
PassMode::Direct(_) | PassMode::Pair(..) => self.ret.layout.immediate_llvm_type(cx),
341-
PassMode::Cast(cast) => cast.llvm_type(cx),
339+
PassMode::Cast(cast, _) => cast.llvm_type(cx),
342340
PassMode::Indirect { .. } => {
343341
llargument_tys.push(cx.type_ptr_to(self.ret.memory_ty(cx)));
344342
cx.type_void()
345343
}
346344
};
347345

348346
for arg in args {
349-
// add padding
350-
if let Some(ty) = arg.pad {
351-
llargument_tys.push(ty.llvm_type(cx));
352-
}
353-
354-
let llarg_ty = match arg.mode {
347+
let llarg_ty = match &arg.mode {
355348
PassMode::Ignore => continue,
356349
PassMode::Direct(_) => arg.layout.immediate_llvm_type(cx),
357350
PassMode::Pair(..) => {
@@ -366,7 +359,13 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
366359
llargument_tys.push(ptr_layout.scalar_pair_element_llvm_type(cx, 1, true));
367360
continue;
368361
}
369-
PassMode::Cast(cast) => cast.llvm_type(cx),
362+
PassMode::Cast(cast, pad_i32) => {
363+
// add padding
364+
if *pad_i32 {
365+
llargument_tys.push(Reg::i32().llvm_type(cx));
366+
}
367+
cast.llvm_type(cx)
368+
}
370369
PassMode::Indirect { attrs: _, extra_attrs: None, on_stack: _ } => {
371370
cx.type_ptr_to(arg.memory_ty(cx))
372371
}
@@ -426,46 +425,46 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
426425
i += 1;
427426
i - 1
428427
};
429-
match self.ret.mode {
430-
PassMode::Direct(ref attrs) => {
428+
match &self.ret.mode {
429+
PassMode::Direct(attrs) => {
431430
attrs.apply_attrs_to_llfn(llvm::AttributePlace::ReturnValue, cx, llfn);
432431
}
433-
PassMode::Indirect { ref attrs, extra_attrs: _, on_stack } => {
432+
PassMode::Indirect { attrs, extra_attrs: _, on_stack } => {
434433
assert!(!on_stack);
435434
let i = apply(attrs);
436435
let sret = llvm::CreateStructRetAttr(cx.llcx, self.ret.layout.llvm_type(cx));
437436
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Argument(i), &[sret]);
438437
}
439-
PassMode::Cast(cast) => {
438+
PassMode::Cast(cast, _) => {
440439
cast.attrs.apply_attrs_to_llfn(llvm::AttributePlace::ReturnValue, cx, llfn);
441440
}
442441
_ => {}
443442
}
444-
for arg in &self.args {
445-
if arg.pad.is_some() {
446-
apply(&ArgAttributes::new());
447-
}
448-
match arg.mode {
443+
for arg in self.args.iter() {
444+
match &arg.mode {
449445
PassMode::Ignore => {}
450-
PassMode::Indirect { ref attrs, extra_attrs: None, on_stack: true } => {
446+
PassMode::Indirect { attrs, extra_attrs: None, on_stack: true } => {
451447
let i = apply(attrs);
452448
let byval = llvm::CreateByValAttr(cx.llcx, arg.layout.llvm_type(cx));
453449
attributes::apply_to_llfn(llfn, llvm::AttributePlace::Argument(i), &[byval]);
454450
}
455-
PassMode::Direct(ref attrs)
456-
| PassMode::Indirect { ref attrs, extra_attrs: None, on_stack: false } => {
451+
PassMode::Direct(attrs)
452+
| PassMode::Indirect { attrs, extra_attrs: None, on_stack: false } => {
457453
apply(attrs);
458454
}
459-
PassMode::Indirect { ref attrs, extra_attrs: Some(ref extra_attrs), on_stack } => {
455+
PassMode::Indirect { attrs, extra_attrs: Some(extra_attrs), on_stack } => {
460456
assert!(!on_stack);
461457
apply(attrs);
462458
apply(extra_attrs);
463459
}
464-
PassMode::Pair(ref a, ref b) => {
460+
PassMode::Pair(a, b) => {
465461
apply(a);
466462
apply(b);
467463
}
468-
PassMode::Cast(cast) => {
464+
PassMode::Cast(cast, pad_i32) => {
465+
if *pad_i32 {
466+
apply(&ArgAttributes::new());
467+
}
469468
apply(&cast.attrs);
470469
}
471470
}
@@ -488,17 +487,17 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
488487
i += 1;
489488
i - 1
490489
};
491-
match self.ret.mode {
492-
PassMode::Direct(ref attrs) => {
490+
match &self.ret.mode {
491+
PassMode::Direct(attrs) => {
493492
attrs.apply_attrs_to_callsite(llvm::AttributePlace::ReturnValue, bx.cx, callsite);
494493
}
495-
PassMode::Indirect { ref attrs, extra_attrs: _, on_stack } => {
494+
PassMode::Indirect { attrs, extra_attrs: _, on_stack } => {
496495
assert!(!on_stack);
497496
let i = apply(bx.cx, attrs);
498497
let sret = llvm::CreateStructRetAttr(bx.cx.llcx, self.ret.layout.llvm_type(bx));
499498
attributes::apply_to_callsite(callsite, llvm::AttributePlace::Argument(i), &[sret]);
500499
}
501-
PassMode::Cast(cast) => {
500+
PassMode::Cast(cast, _) => {
502501
cast.attrs.apply_attrs_to_callsite(
503502
llvm::AttributePlace::ReturnValue,
504503
&bx.cx,
@@ -517,13 +516,10 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
517516
}
518517
}
519518
}
520-
for arg in &self.args {
521-
if arg.pad.is_some() {
522-
apply(bx.cx, &ArgAttributes::new());
523-
}
524-
match arg.mode {
519+
for arg in self.args.iter() {
520+
match &arg.mode {
525521
PassMode::Ignore => {}
526-
PassMode::Indirect { ref attrs, extra_attrs: None, on_stack: true } => {
522+
PassMode::Indirect { attrs, extra_attrs: None, on_stack: true } => {
527523
let i = apply(bx.cx, attrs);
528524
let byval = llvm::CreateByValAttr(bx.cx.llcx, arg.layout.llvm_type(bx));
529525
attributes::apply_to_callsite(
@@ -532,23 +528,22 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
532528
&[byval],
533529
);
534530
}
535-
PassMode::Direct(ref attrs)
536-
| PassMode::Indirect { ref attrs, extra_attrs: None, on_stack: false } => {
531+
PassMode::Direct(attrs)
532+
| PassMode::Indirect { attrs, extra_attrs: None, on_stack: false } => {
537533
apply(bx.cx, attrs);
538534
}
539-
PassMode::Indirect {
540-
ref attrs,
541-
extra_attrs: Some(ref extra_attrs),
542-
on_stack: _,
543-
} => {
535+
PassMode::Indirect { attrs, extra_attrs: Some(extra_attrs), on_stack: _ } => {
544536
apply(bx.cx, attrs);
545537
apply(bx.cx, extra_attrs);
546538
}
547-
PassMode::Pair(ref a, ref b) => {
539+
PassMode::Pair(a, b) => {
548540
apply(bx.cx, a);
549541
apply(bx.cx, b);
550542
}
551-
PassMode::Cast(cast) => {
543+
PassMode::Cast(cast, pad_i32) => {
544+
if *pad_i32 {
545+
apply(bx.cx, &ArgAttributes::new());
546+
}
552547
apply(bx.cx, &cast.attrs);
553548
}
554549
}

‎compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
161161
sym::volatile_load | sym::unaligned_volatile_load => {
162162
let tp_ty = substs.type_at(0);
163163
let ptr = args[0].immediate();
164-
let load = if let PassMode::Cast(ty) = fn_abi.ret.mode {
164+
let load = if let PassMode::Cast(ty, _) = &fn_abi.ret.mode {
165165
let llty = ty.llvm_type(self);
166166
let ptr = self.pointercast(ptr, self.type_ptr_to(llty));
167167
self.volatile_load(llty, ptr)
@@ -374,7 +374,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
374374
};
375375

376376
if !fn_abi.ret.is_ignore() {
377-
if let PassMode::Cast(ty) = fn_abi.ret.mode {
377+
if let PassMode::Cast(ty, _) = &fn_abi.ret.mode {
378378
let ptr_llty = self.type_ptr_to(ty.llvm_type(self));
379379
let ptr = self.pointercast(result.llval, ptr_llty);
380380
self.store(llval, ptr, result.align);

‎compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use rustc_middle::ty::{self, Instance, Ty, TypeVisitable};
2121
use rustc_span::source_map::Span;
2222
use rustc_span::{sym, Symbol};
2323
use rustc_symbol_mangling::typeid::typeid_for_fnabi;
24-
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
24+
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode, Reg};
2525
use rustc_target::abi::{self, HasDataLayout, WrappingRange};
2626
use rustc_target::spec::abi::Abi;
2727

@@ -324,7 +324,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
324324
bx.unreachable();
325325
return;
326326
}
327-
let llval = match self.fn_abi.ret.mode {
327+
let llval = match &self.fn_abi.ret.mode {
328328
PassMode::Ignore | PassMode::Indirect { .. } => {
329329
bx.ret_void();
330330
return;
@@ -339,7 +339,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
339339
}
340340
}
341341

342-
PassMode::Cast(cast_ty) => {
342+
PassMode::Cast(cast_ty, _) => {
343343
let op = match self.locals[mir::RETURN_PLACE] {
344344
LocalRef::Operand(Some(op)) => op,
345345
LocalRef::Operand(None) => bug!("use of return before def"),
@@ -360,7 +360,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
360360
llval
361361
}
362362
};
363-
let ty = bx.cast_backend_type(&cast_ty);
363+
let ty = bx.cast_backend_type(cast_ty);
364364
let addr = bx.pointercast(llslot, bx.type_ptr_to(ty));
365365
bx.load(ty, addr, self.fn_abi.ret.layout.align.abi)
366366
}
@@ -1158,39 +1158,35 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
11581158
llargs: &mut Vec<Bx::Value>,
11591159
arg: &ArgAbi<'tcx, Ty<'tcx>>,
11601160
) {
1161-
// Fill padding with undef value, where applicable.
1162-
if let Some(ty) = arg.pad {
1163-
llargs.push(bx.const_undef(bx.reg_backend_type(&ty)))
1164-
}
1165-
1166-
if arg.is_ignore() {
1167-
return;
1168-
}
1169-
1170-
if let PassMode::Pair(..) = arg.mode {
1171-
match op.val {
1161+
match arg.mode {
1162+
PassMode::Ignore => return,
1163+
PassMode::Cast(_, true) => {
1164+
// Fill padding with undef value, where applicable.
1165+
llargs.push(bx.const_undef(bx.reg_backend_type(&Reg::i32())));
1166+
}
1167+
PassMode::Pair(..) => match op.val {
11721168
Pair(a, b) => {
11731169
llargs.push(a);
11741170
llargs.push(b);
11751171
return;
11761172
}
11771173
_ => bug!("codegen_argument: {:?} invalid for pair argument", op),
1178-
}
1179-
} else if arg.is_unsized_indirect() {
1180-
match op.val {
1174+
},
1175+
PassMode::Indirect { attrs: _, extra_attrs: Some(_), on_stack: _ } => match op.val {
11811176
Ref(a, Some(b), _) => {
11821177
llargs.push(a);
11831178
llargs.push(b);
11841179
return;
11851180
}
11861181
_ => bug!("codegen_argument: {:?} invalid for unsized indirect argument", op),
1187-
}
1182+
},
1183+
_ => {}
11881184
}
11891185

11901186
// Force by-ref if we have to load through a cast pointer.
11911187
let (mut llval, align, by_ref) = match op.val {
11921188
Immediate(_) | Pair(..) => match arg.mode {
1193-
PassMode::Indirect { .. } | PassMode::Cast(_) => {
1189+
PassMode::Indirect { .. } | PassMode::Cast(..) => {
11941190
let scratch = PlaceRef::alloca(bx, arg.layout);
11951191
op.val.store(bx, scratch);
11961192
(scratch.llval, scratch.align, true)
@@ -1222,8 +1218,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
12221218

12231219
if by_ref && !arg.is_indirect() {
12241220
// Have to load the argument, maybe while casting it.
1225-
if let PassMode::Cast(ty) = arg.mode {
1226-
let llty = bx.cast_backend_type(&ty);
1221+
if let PassMode::Cast(ty, _) = &arg.mode {
1222+
let llty = bx.cast_backend_type(ty);
12271223
let addr = bx.pointercast(llval, bx.type_ptr_to(llty));
12281224
llval = bx.load(llty, addr, align.min(arg.layout.align.abi));
12291225
} else {
@@ -1622,7 +1618,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
16221618
}
16231619
DirectOperand(index) => {
16241620
// If there is a cast, we have to store and reload.
1625-
let op = if let PassMode::Cast(_) = ret_abi.mode {
1621+
let op = if let PassMode::Cast(..) = ret_abi.mode {
16261622
let tmp = PlaceRef::alloca(bx, ret_abi.layout);
16271623
tmp.storage_live(bx);
16281624
bx.store_arg(&ret_abi, llval, tmp);

‎compiler/rustc_codegen_ssa/src/mir/intrinsic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -597,8 +597,8 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
597597
};
598598

599599
if !fn_abi.ret.is_ignore() {
600-
if let PassMode::Cast(ty) = fn_abi.ret.mode {
601-
let ptr_llty = bx.type_ptr_to(bx.cast_backend_type(&ty));
600+
if let PassMode::Cast(ty, _) = &fn_abi.ret.mode {
601+
let ptr_llty = bx.type_ptr_to(bx.cast_backend_type(ty));
602602
let ptr = bx.pointercast(result.llval, ptr_llty);
603603
bx.store(llval, ptr, result.align);
604604
} else {

‎compiler/rustc_codegen_ssa/src/mir/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
283283
for i in 0..tupled_arg_tys.len() {
284284
let arg = &fx.fn_abi.args[idx];
285285
idx += 1;
286-
if arg.pad.is_some() {
286+
if let PassMode::Cast(_, true) = arg.mode {
287287
llarg_idx += 1;
288288
}
289289
let pr_field = place.project_field(bx, i);
@@ -309,7 +309,7 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
309309

310310
let arg = &fx.fn_abi.args[idx];
311311
idx += 1;
312-
if arg.pad.is_some() {
312+
if let PassMode::Cast(_, true) = arg.mode {
313313
llarg_idx += 1;
314314
}
315315

‎compiler/rustc_const_eval/src/interpret/terminator.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
214214
_ => false,
215215
}
216216
};
217-
// Padding must be fully equal.
218-
let pad_compat = || caller_abi.pad == callee_abi.pad;
219217
// When comparing the PassMode, we have to be smart about comparing the attributes.
220-
let arg_attr_compat = |a1: ArgAttributes, a2: ArgAttributes| {
218+
let arg_attr_compat = |a1: &ArgAttributes, a2: &ArgAttributes| {
221219
// There's only one regular attribute that matters for the call ABI: InReg.
222220
// Everything else is things like noalias, dereferencable, nonnull, ...
223221
// (This also applies to pointee_size, pointee_align.)
@@ -232,13 +230,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
232230
}
233231
return true;
234232
};
235-
let mode_compat = || match (caller_abi.mode, callee_abi.mode) {
233+
let mode_compat = || match (&caller_abi.mode, &callee_abi.mode) {
236234
(PassMode::Ignore, PassMode::Ignore) => true,
237235
(PassMode::Direct(a1), PassMode::Direct(a2)) => arg_attr_compat(a1, a2),
238236
(PassMode::Pair(a1, b1), PassMode::Pair(a2, b2)) => {
239237
arg_attr_compat(a1, a2) && arg_attr_compat(b1, b2)
240238
}
241-
(PassMode::Cast(c1), PassMode::Cast(c2)) => c1 == c2,
239+
(PassMode::Cast(c1, pad1), PassMode::Cast(c2, pad2)) => c1 == c2 && pad1 == pad2,
242240
(
243241
PassMode::Indirect { attrs: a1, extra_attrs: None, on_stack: s1 },
244242
PassMode::Indirect { attrs: a2, extra_attrs: None, on_stack: s2 },
@@ -250,7 +248,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
250248
_ => false,
251249
};
252250

253-
if layout_compat() && pad_compat() && mode_compat() {
251+
if layout_compat() && mode_compat() {
254252
return true;
255253
}
256254
trace!(

‎compiler/rustc_middle/src/ty/layout.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3251,7 +3251,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
32513251
.map(|(i, ty)| arg_of(ty, Some(i)))
32523252
.collect::<Result<_, _>>()?,
32533253
c_variadic: sig.c_variadic,
3254-
fixed_count: inputs.len(),
3254+
fixed_count: inputs.len() as u32,
32553255
conv,
32563256
can_unwind: fn_can_unwind(self.tcx(), fn_def_id, sig.abi),
32573257
};
@@ -3323,7 +3323,7 @@ impl<'tcx> LayoutCx<'tcx, TyCtxt<'tcx>> {
33233323
}
33243324
};
33253325
fixup(&mut fn_abi.ret);
3326-
for arg in &mut fn_abi.args {
3326+
for arg in fn_abi.args.iter_mut() {
33273327
fixup(arg);
33283328
}
33293329
} else {

‎compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -888,7 +888,7 @@ pub fn typeid_for_fnabi<'tcx>(
888888
typeid.push('v');
889889
}
890890
} else {
891-
for n in 0..fn_abi.fixed_count {
891+
for n in 0..fn_abi.fixed_count as usize {
892892
let ty = transform_ty(tcx, fn_abi.args[n].layout.ty, transform_ty_options);
893893
typeid.push_str(&encode_ty(tcx, ty, &mut dict, encode_ty_options));
894894
}

‎compiler/rustc_target/src/abi/call/aarch64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ where
7777
classify_ret(cx, &mut fn_abi.ret);
7878
}
7979

80-
for arg in &mut fn_abi.args {
80+
for arg in fn_abi.args.iter_mut() {
8181
if arg.is_ignore() {
8282
continue;
8383
}

‎compiler/rustc_target/src/abi/call/amdgpu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ where
2626
classify_ret(cx, &mut fn_abi.ret);
2727
}
2828

29-
for arg in &mut fn_abi.args {
29+
for arg in fn_abi.args.iter_mut() {
3030
if arg.is_ignore() {
3131
continue;
3232
}

‎compiler/rustc_target/src/abi/call/arm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ where
8888
classify_ret(cx, &mut fn_abi.ret, vfp);
8989
}
9090

91-
for arg in &mut fn_abi.args {
91+
for arg in fn_abi.args.iter_mut() {
9292
if arg.is_ignore() {
9393
continue;
9494
}

‎compiler/rustc_target/src/abi/call/avr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn compute_abi_info<Ty>(fty: &mut FnAbi<'_, Ty>) {
4949
classify_ret_ty(&mut fty.ret);
5050
}
5151

52-
for arg in &mut fty.args {
52+
for arg in fty.args.iter_mut() {
5353
if arg.is_ignore() {
5454
continue;
5555
}

‎compiler/rustc_target/src/abi/call/bpf.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
2222
classify_ret(&mut fn_abi.ret);
2323
}
2424

25-
for arg in &mut fn_abi.args {
25+
for arg in fn_abi.args.iter_mut() {
2626
if arg.is_ignore() {
2727
continue;
2828
}

‎compiler/rustc_target/src/abi/call/hexagon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
2121
classify_ret(&mut fn_abi.ret);
2222
}
2323

24-
for arg in &mut fn_abi.args {
24+
for arg in fn_abi.args.iter_mut() {
2525
if arg.is_ignore() {
2626
continue;
2727
}

‎compiler/rustc_target/src/abi/call/m68k.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
2121
classify_ret(&mut fn_abi.ret);
2222
}
2323

24-
for arg in &mut fn_abi.args {
24+
for arg in fn_abi.args.iter_mut() {
2525
if arg.is_ignore() {
2626
continue;
2727
}

‎compiler/rustc_target/src/abi/call/mips.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ where
2222
let align = arg.layout.align.max(dl.i32_align).min(dl.i64_align).abi;
2323

2424
if arg.layout.is_aggregate() {
25-
arg.cast_to(Uniform { unit: Reg::i32(), total: size });
26-
if !offset.is_aligned(align) {
27-
arg.pad_with(Reg::i32());
28-
}
25+
let pad_i32 = !offset.is_aligned(align);
26+
arg.cast_to_and_pad_i32(Uniform { unit: Reg::i32(), total: size }, pad_i32);
2927
} else {
3028
arg.extend_integer_width_to(32);
3129
}
@@ -42,7 +40,7 @@ where
4240
classify_ret(cx, &mut fn_abi.ret, &mut offset);
4341
}
4442

45-
for arg in &mut fn_abi.args {
43+
for arg in fn_abi.args.iter_mut() {
4644
if arg.is_ignore() {
4745
continue;
4846
}

‎compiler/rustc_target/src/abi/call/mips64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ where
158158
classify_ret(cx, &mut fn_abi.ret);
159159
}
160160

161-
for arg in &mut fn_abi.args {
161+
for arg in fn_abi.args.iter_mut() {
162162
if arg.is_ignore() {
163163
continue;
164164
}

‎compiler/rustc_target/src/abi/call/mod.rs

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod x86;
2626
mod x86_64;
2727
mod x86_win64;
2828

29-
#[derive(Clone, Copy, PartialEq, Eq, Hash, Debug, HashStable_Generic)]
29+
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
3030
pub enum PassMode {
3131
/// Ignore the argument.
3232
///
@@ -40,9 +40,10 @@ pub enum PassMode {
4040
///
4141
/// The argument has a layout abi of `ScalarPair`.
4242
Pair(ArgAttributes, ArgAttributes),
43-
/// Pass the argument after casting it, to either
44-
/// a single uniform or a pair of registers.
45-
Cast(CastTarget),
43+
/// Pass the argument after casting it, to either a single uniform or a
44+
/// pair of registers. The bool indicates if a `Reg::i32()` dummy argument
45+
/// is emitted before the real argument.
46+
Cast(Box<CastTarget>, bool),
4647
/// Pass the argument indirectly via a hidden pointer.
4748
/// The `extra_attrs` value, if any, is for the extra data (vtable or length)
4849
/// which indicates that it refers to an unsized rvalue.
@@ -463,10 +464,6 @@ impl<'a, Ty> TyAndLayout<'a, Ty> {
463464
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
464465
pub struct ArgAbi<'a, Ty> {
465466
pub layout: TyAndLayout<'a, Ty>,
466-
467-
/// Dummy argument, which is emitted before the real argument.
468-
pub pad: Option<Reg>,
469-
470467
pub mode: PassMode,
471468
}
472469

@@ -486,7 +483,7 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
486483
Abi::Vector { .. } => PassMode::Direct(ArgAttributes::new()),
487484
Abi::Aggregate { .. } => PassMode::Direct(ArgAttributes::new()),
488485
};
489-
ArgAbi { layout, pad: None, mode }
486+
ArgAbi { layout, mode }
490487
}
491488

492489
fn indirect_pass_mode(layout: &TyAndLayout<'a, Ty>) -> PassMode {
@@ -548,11 +545,11 @@ impl<'a, Ty> ArgAbi<'a, Ty> {
548545
}
549546

550547
pub fn cast_to<T: Into<CastTarget>>(&mut self, target: T) {
551-
self.mode = PassMode::Cast(target.into());
548+
self.mode = PassMode::Cast(Box::new(target.into()), false);
552549
}
553550

554-
pub fn pad_with(&mut self, reg: Reg) {
555-
self.pad = Some(reg);
551+
pub fn cast_to_and_pad_i32<T: Into<CastTarget>>(&mut self, target: T, pad_i32: bool) {
552+
self.mode = PassMode::Cast(Box::new(target.into()), pad_i32);
556553
}
557554

558555
pub fn is_indirect(&self) -> bool {
@@ -614,7 +611,7 @@ pub enum Conv {
614611
#[derive(PartialEq, Eq, Hash, Debug, HashStable_Generic)]
615612
pub struct FnAbi<'a, Ty> {
616613
/// The LLVM types of each argument.
617-
pub args: Vec<ArgAbi<'a, Ty>>,
614+
pub args: Box<[ArgAbi<'a, Ty>]>,
618615

619616
/// LLVM return type.
620617
pub ret: ArgAbi<'a, Ty>,
@@ -625,7 +622,7 @@ pub struct FnAbi<'a, Ty> {
625622
///
626623
/// Should only be different from args.len() when c_variadic is true.
627624
/// This can be used to know whether an argument is variadic or not.
628-
pub fixed_count: usize,
625+
pub fixed_count: u32,
629626

630627
pub conv: Conv,
631628

@@ -730,3 +727,13 @@ impl<'a, Ty> FnAbi<'a, Ty> {
730727
Ok(())
731728
}
732729
}
730+
731+
// Some types are used a lot. Make sure they don't unintentionally get bigger.
732+
#[cfg(all(target_arch = "x86_64", target_pointer_width = "64"))]
733+
mod size_asserts {
734+
use super::*;
735+
use rustc_data_structures::static_assert_size;
736+
// These are in alphabetical order, which is easy to maintain.
737+
static_assert_size!(ArgAbi<'_, usize>, 56);
738+
static_assert_size!(FnAbi<'_, usize>, 80);
739+
}

‎compiler/rustc_target/src/abi/call/msp430.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
3030
classify_ret(&mut fn_abi.ret);
3131
}
3232

33-
for arg in &mut fn_abi.args {
33+
for arg in fn_abi.args.iter_mut() {
3434
if arg.is_ignore() {
3535
continue;
3636
}

‎compiler/rustc_target/src/abi/call/nvptx64.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
3838
classify_ret(&mut fn_abi.ret);
3939
}
4040

41-
for arg in &mut fn_abi.args {
41+
for arg in fn_abi.args.iter_mut() {
4242
if arg.is_ignore() {
4343
continue;
4444
}
@@ -55,7 +55,7 @@ where
5555
panic!("Kernels should not return anything other than () or !");
5656
}
5757

58-
for arg in &mut fn_abi.args {
58+
for arg in fn_abi.args.iter_mut() {
5959
if arg.is_ignore() {
6060
continue;
6161
}

‎compiler/rustc_target/src/abi/call/powerpc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
2121
classify_ret(&mut fn_abi.ret);
2222
}
2323

24-
for arg in &mut fn_abi.args {
24+
for arg in fn_abi.args.iter_mut() {
2525
if arg.is_ignore() {
2626
continue;
2727
}

‎compiler/rustc_target/src/abi/call/powerpc64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ where
132132
classify_ret(cx, &mut fn_abi.ret, abi);
133133
}
134134

135-
for arg in &mut fn_abi.args {
135+
for arg in fn_abi.args.iter_mut() {
136136
if arg.is_ignore() {
137137
continue;
138138
}

‎compiler/rustc_target/src/abi/call/riscv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ where
340340
arg,
341341
xlen,
342342
flen,
343-
i >= fn_abi.fixed_count,
343+
i >= fn_abi.fixed_count as usize,
344344
&mut avail_gprs,
345345
&mut avail_fprs,
346346
);

‎compiler/rustc_target/src/abi/call/s390x.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ where
4848
classify_ret(&mut fn_abi.ret);
4949
}
5050

51-
for arg in &mut fn_abi.args {
51+
for arg in fn_abi.args.iter_mut() {
5252
if arg.is_ignore() {
5353
continue;
5454
}

‎compiler/rustc_target/src/abi/call/sparc.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@ where
2222
let align = arg.layout.align.max(dl.i32_align).min(dl.i64_align).abi;
2323

2424
if arg.layout.is_aggregate() {
25-
arg.cast_to(Uniform { unit: Reg::i32(), total: size });
26-
if !offset.is_aligned(align) {
27-
arg.pad_with(Reg::i32());
28-
}
25+
let pad_i32 = !offset.is_aligned(align);
26+
arg.cast_to_and_pad_i32(Uniform { unit: Reg::i32(), total: size }, pad_i32);
2927
} else {
3028
arg.extend_integer_width_to(32);
3129
}
@@ -42,7 +40,7 @@ where
4240
classify_ret(cx, &mut fn_abi.ret, &mut offset);
4341
}
4442

45-
for arg in &mut fn_abi.args {
43+
for arg in fn_abi.args.iter_mut() {
4644
if arg.is_ignore() {
4745
continue;
4846
}

‎compiler/rustc_target/src/abi/call/sparc64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ where
217217
classify_arg(cx, &mut fn_abi.ret, Size { raw: 32 });
218218
}
219219

220-
for arg in &mut fn_abi.args {
220+
for arg in fn_abi.args.iter_mut() {
221221
if arg.is_ignore() {
222222
continue;
223223
}

‎compiler/rustc_target/src/abi/call/wasm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ where
5050
classify_ret(cx, &mut fn_abi.ret);
5151
}
5252

53-
for arg in &mut fn_abi.args {
53+
for arg in fn_abi.args.iter_mut() {
5454
if arg.is_ignore() {
5555
continue;
5656
}
@@ -66,7 +66,7 @@ pub fn compute_wasm_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
6666
classify_ret(&mut fn_abi.ret);
6767
}
6868

69-
for arg in &mut fn_abi.args {
69+
for arg in fn_abi.args.iter_mut() {
7070
if arg.is_ignore() {
7171
continue;
7272
}

‎compiler/rustc_target/src/abi/call/x86.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ where
4949
}
5050
}
5151

52-
for arg in &mut fn_abi.args {
52+
for arg in fn_abi.args.iter_mut() {
5353
if arg.is_ignore() {
5454
continue;
5555
}
@@ -72,7 +72,7 @@ where
7272

7373
let mut free_regs = 2;
7474

75-
for arg in &mut fn_abi.args {
75+
for arg in fn_abi.args.iter_mut() {
7676
let attrs = match arg.mode {
7777
PassMode::Ignore
7878
| PassMode::Indirect { attrs: _, extra_attrs: None, on_stack: _ } => {
@@ -81,7 +81,7 @@ where
8181
PassMode::Direct(ref mut attrs) => attrs,
8282
PassMode::Pair(..)
8383
| PassMode::Indirect { attrs: _, extra_attrs: Some(_), on_stack: _ }
84-
| PassMode::Cast(_) => {
84+
| PassMode::Cast(..) => {
8585
unreachable!("x86 shouldn't be passing arguments by {:?}", arg.mode)
8686
}
8787
};

‎compiler/rustc_target/src/abi/call/x86_64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ where
239239
x86_64_arg_or_ret(&mut fn_abi.ret, false);
240240
}
241241

242-
for arg in &mut fn_abi.args {
242+
for arg in fn_abi.args.iter_mut() {
243243
if arg.is_ignore() {
244244
continue;
245245
}

‎compiler/rustc_target/src/abi/call/x86_win64.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn compute_abi_info<Ty>(fn_abi: &mut FnAbi<'_, Ty>) {
3131
if !fn_abi.ret.is_ignore() {
3232
fixup(&mut fn_abi.ret);
3333
}
34-
for arg in &mut fn_abi.args {
34+
for arg in fn_abi.args.iter_mut() {
3535
if arg.is_ignore() {
3636
continue;
3737
}

0 commit comments

Comments
 (0)
Please sign in to comment.