Skip to content

Commit 9a2362e

Browse files
committed
Shrink the size of Rvalue by 16 bytes
1 parent f314813 commit 9a2362e

File tree

29 files changed

+83
-67
lines changed

29 files changed

+83
-67
lines changed

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -494,14 +494,14 @@ fn codegen_stmt<'tcx>(
494494
let val = crate::constant::codegen_tls_ref(fx, def_id, lval.layout());
495495
lval.write_cvalue(fx, val);
496496
}
497-
Rvalue::BinaryOp(bin_op, ref lhs, ref rhs) => {
497+
Rvalue::BinaryOp(bin_op, box (ref lhs, ref rhs)) => {
498498
let lhs = codegen_operand(fx, lhs);
499499
let rhs = codegen_operand(fx, rhs);
500500

501501
let res = crate::num::codegen_binop(fx, bin_op, lhs, rhs);
502502
lval.write_cvalue(fx, res);
503503
}
504-
Rvalue::CheckedBinaryOp(bin_op, ref lhs, ref rhs) => {
504+
Rvalue::CheckedBinaryOp(bin_op, box (ref lhs, ref rhs)) => {
505505
let lhs = codegen_operand(fx, lhs);
506506
let rhs = codegen_operand(fx, rhs);
507507

compiler/rustc_codegen_cranelift/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
associated_type_bounds,
66
never_type,
77
try_blocks,
8+
box_patterns,
89
hash_drain_filter
910
)]
1011
#![warn(rust_2018_idioms)]

compiler/rustc_codegen_ssa/src/mir/rvalue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
424424
(bx, operand)
425425
}
426426

427-
mir::Rvalue::BinaryOp(op, ref lhs, ref rhs) => {
427+
mir::Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => {
428428
let lhs = self.codegen_operand(&mut bx, lhs);
429429
let rhs = self.codegen_operand(&mut bx, rhs);
430430
let llresult = match (lhs.val, rhs.val) {
@@ -453,7 +453,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
453453
};
454454
(bx, operand)
455455
}
456-
mir::Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => {
456+
mir::Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => {
457457
let lhs = self.codegen_operand(&mut bx, lhs);
458458
let rhs = self.codegen_operand(&mut bx, rhs);
459459
let result = self.codegen_scalar_checked_binop(

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2076,8 +2076,8 @@ pub enum Rvalue<'tcx> {
20762076

20772077
Cast(CastKind, Operand<'tcx>, Ty<'tcx>),
20782078

2079-
BinaryOp(BinOp, Operand<'tcx>, Operand<'tcx>),
2080-
CheckedBinaryOp(BinOp, Operand<'tcx>, Operand<'tcx>),
2079+
BinaryOp(BinOp, Box<(Operand<'tcx>, Operand<'tcx>)>),
2080+
CheckedBinaryOp(BinOp, Box<(Operand<'tcx>, Operand<'tcx>)>),
20812081

20822082
NullaryOp(NullOp, Ty<'tcx>),
20832083
UnaryOp(UnOp, Operand<'tcx>),
@@ -2097,7 +2097,7 @@ pub enum Rvalue<'tcx> {
20972097
}
20982098

20992099
#[cfg(target_arch = "x86_64")]
2100-
static_assert_size!(Rvalue<'_>, 56);
2100+
static_assert_size!(Rvalue<'_>, 40);
21012101

21022102
#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
21032103
pub enum CastKind {
@@ -2201,8 +2201,8 @@ impl<'tcx> Debug for Rvalue<'tcx> {
22012201
Cast(ref kind, ref place, ref ty) => {
22022202
write!(fmt, "{:?} as {:?} ({:?})", place, ty, kind)
22032203
}
2204-
BinaryOp(ref op, ref a, ref b) => write!(fmt, "{:?}({:?}, {:?})", op, a, b),
2205-
CheckedBinaryOp(ref op, ref a, ref b) => {
2204+
BinaryOp(ref op, box (ref a, ref b)) => write!(fmt, "{:?}({:?}, {:?})", op, a, b),
2205+
CheckedBinaryOp(ref op, box (ref a, ref b)) => {
22062206
write!(fmt, "Checked{:?}({:?}, {:?})", op, a, b)
22072207
}
22082208
UnaryOp(ref op, ref a) => write!(fmt, "{:?}({:?})", op, a),

compiler/rustc_middle/src/mir/tcx.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,12 @@ impl<'tcx> Rvalue<'tcx> {
182182
}
183183
Rvalue::Len(..) => tcx.types.usize,
184184
Rvalue::Cast(.., ty) => ty,
185-
Rvalue::BinaryOp(op, ref lhs, ref rhs) => {
185+
Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => {
186186
let lhs_ty = lhs.ty(local_decls, tcx);
187187
let rhs_ty = rhs.ty(local_decls, tcx);
188188
op.ty(tcx, lhs_ty, rhs_ty)
189189
}
190-
Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => {
190+
Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => {
191191
let lhs_ty = lhs.ty(local_decls, tcx);
192192
let rhs_ty = rhs.ty(local_decls, tcx);
193193
let ty = op.ty(tcx, lhs_ty, rhs_ty);

compiler/rustc_middle/src/mir/type_foldable.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,9 +181,11 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
181181
AddressOf(mutability, place) => AddressOf(mutability, place.fold_with(folder)),
182182
Len(place) => Len(place.fold_with(folder)),
183183
Cast(kind, op, ty) => Cast(kind, op.fold_with(folder), ty.fold_with(folder)),
184-
BinaryOp(op, rhs, lhs) => BinaryOp(op, rhs.fold_with(folder), lhs.fold_with(folder)),
185-
CheckedBinaryOp(op, rhs, lhs) => {
186-
CheckedBinaryOp(op, rhs.fold_with(folder), lhs.fold_with(folder))
184+
BinaryOp(op, box (rhs, lhs)) => {
185+
BinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder)))
186+
}
187+
CheckedBinaryOp(op, box (rhs, lhs)) => {
188+
CheckedBinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder)))
187189
}
188190
UnaryOp(op, val) => UnaryOp(op, val.fold_with(folder)),
189191
Discriminant(place) => Discriminant(place.fold_with(folder)),
@@ -227,7 +229,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
227229
op.visit_with(visitor)?;
228230
ty.visit_with(visitor)
229231
}
230-
BinaryOp(_, ref rhs, ref lhs) | CheckedBinaryOp(_, ref rhs, ref lhs) => {
232+
BinaryOp(_, box (ref rhs, ref lhs)) | CheckedBinaryOp(_, box (ref rhs, ref lhs)) => {
231233
rhs.visit_with(visitor)?;
232234
lhs.visit_with(visitor)
233235
}

compiler/rustc_middle/src/mir/visit.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,8 @@ macro_rules! make_mir_visitor {
685685
self.visit_ty(ty, TyContext::Location(location));
686686
}
687687

688-
Rvalue::BinaryOp(_bin_op, lhs, rhs)
689-
| Rvalue::CheckedBinaryOp(_bin_op, lhs, rhs) => {
688+
Rvalue::BinaryOp(_bin_op, box(lhs, rhs))
689+
| Rvalue::CheckedBinaryOp(_bin_op, box(lhs, rhs)) => {
690690
self.visit_operand(lhs, location);
691691
self.visit_operand(rhs, location);
692692
}

compiler/rustc_mir/src/borrow_check/invalidation.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
326326
);
327327
}
328328

329-
Rvalue::BinaryOp(_bin_op, ref operand1, ref operand2)
330-
| Rvalue::CheckedBinaryOp(_bin_op, ref operand1, ref operand2) => {
329+
Rvalue::BinaryOp(_bin_op, box (ref operand1, ref operand2))
330+
| Rvalue::CheckedBinaryOp(_bin_op, box (ref operand1, ref operand2)) => {
331331
self.consume_operand(location, operand1);
332332
self.consume_operand(location, operand2);
333333
}

compiler/rustc_mir/src/borrow_check/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,8 +1316,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
13161316
);
13171317
}
13181318

1319-
Rvalue::BinaryOp(_bin_op, ref operand1, ref operand2)
1320-
| Rvalue::CheckedBinaryOp(_bin_op, ref operand1, ref operand2) => {
1319+
Rvalue::BinaryOp(_bin_op, box (ref operand1, ref operand2))
1320+
| Rvalue::CheckedBinaryOp(_bin_op, box (ref operand1, ref operand2)) => {
13211321
self.consume_operand(location, (operand1, span), flow_state);
13221322
self.consume_operand(location, (operand2, span), flow_state);
13231323
}

compiler/rustc_mir/src/borrow_check/type_check/mod.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2299,8 +2299,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
22992299

23002300
Rvalue::BinaryOp(
23012301
BinOp::Eq | BinOp::Ne | BinOp::Lt | BinOp::Le | BinOp::Gt | BinOp::Ge,
2302-
left,
2303-
right,
2302+
box (left, right),
23042303
) => {
23052304
let ty_left = left.ty(body, tcx);
23062305
match ty_left.kind() {

0 commit comments

Comments
 (0)