mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 06:44:35 +00:00
Auto merge of #82727 - oli-obk:shrinkmem, r=pnkfelix
Test the effect of shrinking the size of Rvalue by 16 bytes r? `@ghost`
This commit is contained in:
commit
27885a94c6
@ -464,14 +464,14 @@ fn codegen_stmt<'tcx>(
|
||||
let val = crate::constant::codegen_tls_ref(fx, def_id, lval.layout());
|
||||
lval.write_cvalue(fx, val);
|
||||
}
|
||||
Rvalue::BinaryOp(bin_op, ref lhs, ref rhs) => {
|
||||
Rvalue::BinaryOp(bin_op, box (ref lhs, ref rhs)) => {
|
||||
let lhs = codegen_operand(fx, lhs);
|
||||
let rhs = codegen_operand(fx, rhs);
|
||||
|
||||
let res = crate::num::codegen_binop(fx, bin_op, lhs, rhs);
|
||||
lval.write_cvalue(fx, res);
|
||||
}
|
||||
Rvalue::CheckedBinaryOp(bin_op, ref lhs, ref rhs) => {
|
||||
Rvalue::CheckedBinaryOp(bin_op, box (ref lhs, ref rhs)) => {
|
||||
let lhs = codegen_operand(fx, lhs);
|
||||
let rhs = codegen_operand(fx, rhs);
|
||||
|
||||
|
@ -5,6 +5,7 @@
|
||||
associated_type_bounds,
|
||||
never_type,
|
||||
try_blocks,
|
||||
box_patterns,
|
||||
hash_drain_filter
|
||||
)]
|
||||
#![warn(rust_2018_idioms)]
|
||||
|
@ -424,7 +424,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
(bx, operand)
|
||||
}
|
||||
|
||||
mir::Rvalue::BinaryOp(op, ref lhs, ref rhs) => {
|
||||
mir::Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => {
|
||||
let lhs = self.codegen_operand(&mut bx, lhs);
|
||||
let rhs = self.codegen_operand(&mut bx, rhs);
|
||||
let llresult = match (lhs.val, rhs.val) {
|
||||
@ -453,7 +453,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
};
|
||||
(bx, operand)
|
||||
}
|
||||
mir::Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => {
|
||||
mir::Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => {
|
||||
let lhs = self.codegen_operand(&mut bx, lhs);
|
||||
let rhs = self.codegen_operand(&mut bx, rhs);
|
||||
let result = self.codegen_scalar_checked_binop(
|
||||
|
@ -1683,6 +1683,9 @@ pub struct Place<'tcx> {
|
||||
pub projection: &'tcx List<PlaceElem<'tcx>>,
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
static_assert_size!(Place<'_>, 16);
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||
#[derive(TyEncodable, TyDecodable, HashStable)]
|
||||
pub enum ProjectionElem<V, T> {
|
||||
@ -1981,6 +1984,9 @@ pub enum Operand<'tcx> {
|
||||
Constant(Box<Constant<'tcx>>),
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
static_assert_size!(Operand<'_>, 24);
|
||||
|
||||
impl<'tcx> Debug for Operand<'tcx> {
|
||||
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
|
||||
use self::Operand::*;
|
||||
@ -2096,8 +2102,8 @@ pub enum Rvalue<'tcx> {
|
||||
|
||||
Cast(CastKind, Operand<'tcx>, Ty<'tcx>),
|
||||
|
||||
BinaryOp(BinOp, Operand<'tcx>, Operand<'tcx>),
|
||||
CheckedBinaryOp(BinOp, Operand<'tcx>, Operand<'tcx>),
|
||||
BinaryOp(BinOp, Box<(Operand<'tcx>, Operand<'tcx>)>),
|
||||
CheckedBinaryOp(BinOp, Box<(Operand<'tcx>, Operand<'tcx>)>),
|
||||
|
||||
NullaryOp(NullOp, Ty<'tcx>),
|
||||
UnaryOp(UnOp, Operand<'tcx>),
|
||||
@ -2116,6 +2122,9 @@ pub enum Rvalue<'tcx> {
|
||||
Aggregate(Box<AggregateKind<'tcx>>, Vec<Operand<'tcx>>),
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
static_assert_size!(Rvalue<'_>, 40);
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
|
||||
pub enum CastKind {
|
||||
Misc,
|
||||
@ -2139,6 +2148,9 @@ pub enum AggregateKind<'tcx> {
|
||||
Generator(DefId, SubstsRef<'tcx>, hir::Movability),
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
static_assert_size!(AggregateKind<'_>, 48);
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, TyEncodable, TyDecodable, Hash, HashStable)]
|
||||
pub enum BinOp {
|
||||
/// The `+` operator (addition)
|
||||
@ -2215,8 +2227,8 @@ impl<'tcx> Debug for Rvalue<'tcx> {
|
||||
Cast(ref kind, ref place, ref ty) => {
|
||||
write!(fmt, "{:?} as {:?} ({:?})", place, ty, kind)
|
||||
}
|
||||
BinaryOp(ref op, ref a, ref b) => write!(fmt, "{:?}({:?}, {:?})", op, a, b),
|
||||
CheckedBinaryOp(ref op, ref a, ref b) => {
|
||||
BinaryOp(ref op, box (ref a, ref b)) => write!(fmt, "{:?}({:?}, {:?})", op, a, b),
|
||||
CheckedBinaryOp(ref op, box (ref a, ref b)) => {
|
||||
write!(fmt, "Checked{:?}({:?}, {:?})", op, a, b)
|
||||
}
|
||||
UnaryOp(ref op, ref a) => write!(fmt, "{:?}({:?})", op, a),
|
||||
|
@ -182,12 +182,12 @@ impl<'tcx> Rvalue<'tcx> {
|
||||
}
|
||||
Rvalue::Len(..) => tcx.types.usize,
|
||||
Rvalue::Cast(.., ty) => ty,
|
||||
Rvalue::BinaryOp(op, ref lhs, ref rhs) => {
|
||||
Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) => {
|
||||
let lhs_ty = lhs.ty(local_decls, tcx);
|
||||
let rhs_ty = rhs.ty(local_decls, tcx);
|
||||
op.ty(tcx, lhs_ty, rhs_ty)
|
||||
}
|
||||
Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => {
|
||||
Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => {
|
||||
let lhs_ty = lhs.ty(local_decls, tcx);
|
||||
let rhs_ty = rhs.ty(local_decls, tcx);
|
||||
let ty = op.ty(tcx, lhs_ty, rhs_ty);
|
||||
|
@ -181,9 +181,11 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
|
||||
AddressOf(mutability, place) => AddressOf(mutability, place.fold_with(folder)),
|
||||
Len(place) => Len(place.fold_with(folder)),
|
||||
Cast(kind, op, ty) => Cast(kind, op.fold_with(folder), ty.fold_with(folder)),
|
||||
BinaryOp(op, rhs, lhs) => BinaryOp(op, rhs.fold_with(folder), lhs.fold_with(folder)),
|
||||
CheckedBinaryOp(op, rhs, lhs) => {
|
||||
CheckedBinaryOp(op, rhs.fold_with(folder), lhs.fold_with(folder))
|
||||
BinaryOp(op, box (rhs, lhs)) => {
|
||||
BinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder)))
|
||||
}
|
||||
CheckedBinaryOp(op, box (rhs, lhs)) => {
|
||||
CheckedBinaryOp(op, box (rhs.fold_with(folder), lhs.fold_with(folder)))
|
||||
}
|
||||
UnaryOp(op, val) => UnaryOp(op, val.fold_with(folder)),
|
||||
Discriminant(place) => Discriminant(place.fold_with(folder)),
|
||||
@ -227,7 +229,7 @@ impl<'tcx> TypeFoldable<'tcx> for Rvalue<'tcx> {
|
||||
op.visit_with(visitor)?;
|
||||
ty.visit_with(visitor)
|
||||
}
|
||||
BinaryOp(_, ref rhs, ref lhs) | CheckedBinaryOp(_, ref rhs, ref lhs) => {
|
||||
BinaryOp(_, box (ref rhs, ref lhs)) | CheckedBinaryOp(_, box (ref rhs, ref lhs)) => {
|
||||
rhs.visit_with(visitor)?;
|
||||
lhs.visit_with(visitor)
|
||||
}
|
||||
|
@ -687,8 +687,8 @@ macro_rules! make_mir_visitor {
|
||||
self.visit_ty(ty, TyContext::Location(location));
|
||||
}
|
||||
|
||||
Rvalue::BinaryOp(_bin_op, lhs, rhs)
|
||||
| Rvalue::CheckedBinaryOp(_bin_op, lhs, rhs) => {
|
||||
Rvalue::BinaryOp(_bin_op, box(lhs, rhs))
|
||||
| Rvalue::CheckedBinaryOp(_bin_op, box(lhs, rhs)) => {
|
||||
self.visit_operand(lhs, location);
|
||||
self.visit_operand(rhs, location);
|
||||
}
|
||||
|
@ -326,8 +326,8 @@ impl<'cx, 'tcx> InvalidationGenerator<'cx, 'tcx> {
|
||||
);
|
||||
}
|
||||
|
||||
Rvalue::BinaryOp(_bin_op, ref operand1, ref operand2)
|
||||
| Rvalue::CheckedBinaryOp(_bin_op, ref operand1, ref operand2) => {
|
||||
Rvalue::BinaryOp(_bin_op, box (ref operand1, ref operand2))
|
||||
| Rvalue::CheckedBinaryOp(_bin_op, box (ref operand1, ref operand2)) => {
|
||||
self.consume_operand(location, operand1);
|
||||
self.consume_operand(location, operand2);
|
||||
}
|
||||
|
@ -1316,8 +1316,8 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
|
||||
);
|
||||
}
|
||||
|
||||
Rvalue::BinaryOp(_bin_op, ref operand1, ref operand2)
|
||||
| Rvalue::CheckedBinaryOp(_bin_op, ref operand1, ref operand2) => {
|
||||
Rvalue::BinaryOp(_bin_op, box (ref operand1, ref operand2))
|
||||
| Rvalue::CheckedBinaryOp(_bin_op, box (ref operand1, ref operand2)) => {
|
||||
self.consume_operand(location, (operand1, span), flow_state);
|
||||
self.consume_operand(location, (operand2, span), flow_state);
|
||||
}
|
||||
|
@ -2299,8 +2299,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
|
||||
|
||||
Rvalue::BinaryOp(
|
||||
BinOp::Eq | BinOp::Ne | BinOp::Lt | BinOp::Le | BinOp::Gt | BinOp::Ge,
|
||||
left,
|
||||
right,
|
||||
box (left, right),
|
||||
) => {
|
||||
let ty_left = left.ty(body, tcx);
|
||||
match ty_left.kind() {
|
||||
|
@ -329,8 +329,8 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
|
||||
| Rvalue::Repeat(ref operand, _)
|
||||
| Rvalue::Cast(_, ref operand, _)
|
||||
| Rvalue::UnaryOp(_, ref operand) => self.gather_operand(operand),
|
||||
Rvalue::BinaryOp(ref _binop, ref lhs, ref rhs)
|
||||
| Rvalue::CheckedBinaryOp(ref _binop, ref lhs, ref rhs) => {
|
||||
Rvalue::BinaryOp(ref _binop, box (ref lhs, ref rhs))
|
||||
| Rvalue::CheckedBinaryOp(ref _binop, box (ref lhs, ref rhs)) => {
|
||||
self.gather_operand(lhs);
|
||||
self.gather_operand(rhs);
|
||||
}
|
||||
|
@ -165,7 +165,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
self.copy_op(&op, &dest)?;
|
||||
}
|
||||
|
||||
BinaryOp(bin_op, ref left, ref right) => {
|
||||
BinaryOp(bin_op, box (ref left, ref right)) => {
|
||||
let layout = binop_left_homogeneous(bin_op).then_some(dest.layout);
|
||||
let left = self.read_immediate(&self.eval_operand(left, layout)?)?;
|
||||
let layout = binop_right_homogeneous(bin_op).then_some(left.layout);
|
||||
@ -173,7 +173,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
self.binop_ignore_overflow(bin_op, &left, &right, &dest)?;
|
||||
}
|
||||
|
||||
CheckedBinaryOp(bin_op, ref left, ref right) => {
|
||||
CheckedBinaryOp(bin_op, box (ref left, ref right)) => {
|
||||
// Due to the extra boolean in the result, we can never reuse the `dest.layout`.
|
||||
let left = self.read_immediate(&self.eval_operand(left, None)?)?;
|
||||
let layout = binop_right_homogeneous(bin_op).then_some(left.layout);
|
||||
|
@ -463,7 +463,7 @@ impl CloneShimBuilder<'tcx> {
|
||||
let cond = self.make_place(Mutability::Mut, tcx.types.bool);
|
||||
let compute_cond = self.make_statement(StatementKind::Assign(box (
|
||||
cond,
|
||||
Rvalue::BinaryOp(BinOp::Ne, Operand::Copy(end), Operand::Copy(beg)),
|
||||
Rvalue::BinaryOp(BinOp::Ne, box (Operand::Copy(end), Operand::Copy(beg))),
|
||||
)));
|
||||
|
||||
// `if end != beg { goto loop_body; } else { goto loop_end; }`
|
||||
@ -536,8 +536,7 @@ impl CloneShimBuilder<'tcx> {
|
||||
Place::from(beg),
|
||||
Rvalue::BinaryOp(
|
||||
BinOp::Add,
|
||||
Operand::Copy(Place::from(beg)),
|
||||
Operand::Constant(self.make_usize(1)),
|
||||
box (Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1))),
|
||||
),
|
||||
)))];
|
||||
self.block(statements, TerminatorKind::Goto { target: BasicBlock::new(1) }, false);
|
||||
@ -590,8 +589,7 @@ impl CloneShimBuilder<'tcx> {
|
||||
Place::from(beg),
|
||||
Rvalue::BinaryOp(
|
||||
BinOp::Add,
|
||||
Operand::Copy(Place::from(beg)),
|
||||
Operand::Constant(self.make_usize(1)),
|
||||
box (Operand::Copy(Place::from(beg)), Operand::Constant(self.make_usize(1))),
|
||||
),
|
||||
)));
|
||||
self.block(vec![statement], TerminatorKind::Goto { target: BasicBlock::new(6) }, true);
|
||||
|
@ -168,7 +168,7 @@ where
|
||||
| Rvalue::UnaryOp(_, operand)
|
||||
| Rvalue::Cast(_, operand, _) => in_operand::<Q, _>(cx, in_local, operand),
|
||||
|
||||
Rvalue::BinaryOp(_, lhs, rhs) | Rvalue::CheckedBinaryOp(_, lhs, rhs) => {
|
||||
Rvalue::BinaryOp(_, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(_, box (lhs, rhs)) => {
|
||||
in_operand::<Q, _>(cx, in_local, lhs) || in_operand::<Q, _>(cx, in_local, rhs)
|
||||
}
|
||||
|
||||
|
@ -684,8 +684,8 @@ impl Visitor<'tcx> for Validator<'mir, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
Rvalue::BinaryOp(op, ref lhs, ref rhs)
|
||||
| Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) => {
|
||||
Rvalue::BinaryOp(op, box (ref lhs, ref rhs))
|
||||
| Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs)) => {
|
||||
let lhs_ty = lhs.ty(self.body, self.tcx);
|
||||
let rhs_ty = rhs.ty(self.body, self.tcx);
|
||||
|
||||
|
@ -676,11 +676,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
trace!("checking UnaryOp(op = {:?}, arg = {:?})", op, arg);
|
||||
self.check_unary_op(*op, arg, source_info)?;
|
||||
}
|
||||
Rvalue::BinaryOp(op, left, right) => {
|
||||
Rvalue::BinaryOp(op, box (left, right)) => {
|
||||
trace!("checking BinaryOp(op = {:?}, left = {:?}, right = {:?})", op, left, right);
|
||||
self.check_binary_op(*op, left, right, source_info)?;
|
||||
}
|
||||
Rvalue::CheckedBinaryOp(op, left, right) => {
|
||||
Rvalue::CheckedBinaryOp(op, box (left, right)) => {
|
||||
trace!(
|
||||
"checking CheckedBinaryOp(op = {:?}, left = {:?}, right = {:?})",
|
||||
op,
|
||||
@ -740,7 +740,8 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
) -> Option<()> {
|
||||
self.use_ecx(|this| {
|
||||
match rvalue {
|
||||
Rvalue::BinaryOp(op, left, right) | Rvalue::CheckedBinaryOp(op, left, right) => {
|
||||
Rvalue::BinaryOp(op, box (left, right))
|
||||
| Rvalue::CheckedBinaryOp(op, box (left, right)) => {
|
||||
let l = this.ecx.eval_operand(left, None);
|
||||
let r = this.ecx.eval_operand(right, None);
|
||||
|
||||
@ -772,7 +773,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
||||
}
|
||||
BinOp::Mul => {
|
||||
if const_arg.layout.ty.is_integral() && arg_value == 0 {
|
||||
if let Rvalue::CheckedBinaryOp(_, _, _) = rvalue {
|
||||
if let Rvalue::CheckedBinaryOp(_, _) = rvalue {
|
||||
let val = Immediate::ScalarPair(
|
||||
const_arg.to_scalar()?.into(),
|
||||
Scalar::from_bool(false).into(),
|
||||
|
@ -91,8 +91,10 @@ impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
|
||||
opt_to_apply.infos[0].first_switch_info.discr_used_in_switch;
|
||||
let not_equal_rvalue = Rvalue::BinaryOp(
|
||||
not_equal,
|
||||
box (
|
||||
Operand::Copy(Place::from(second_discriminant_temp)),
|
||||
Operand::Copy(first_descriminant_place),
|
||||
),
|
||||
);
|
||||
patch.add_statement(
|
||||
end_of_block_location,
|
||||
|
@ -44,7 +44,7 @@ impl<'tcx, 'a> InstCombineContext<'tcx, 'a> {
|
||||
/// Transform boolean comparisons into logical operations.
|
||||
fn combine_bool_cmp(&self, source_info: &SourceInfo, rvalue: &mut Rvalue<'tcx>) {
|
||||
match rvalue {
|
||||
Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), a, b) => {
|
||||
Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), box (a, b)) => {
|
||||
let new = match (op, self.try_eval_bool(a), self.try_eval_bool(b)) {
|
||||
// Transform "Eq(a, true)" ==> "a"
|
||||
(BinOp::Eq, _, Some(true)) => Some(a.clone()),
|
||||
|
@ -59,7 +59,7 @@ impl<'tcx> MirPass<'tcx> for LowerIntrinsics {
|
||||
source_info: terminator.source_info,
|
||||
kind: StatementKind::Assign(box (
|
||||
destination,
|
||||
Rvalue::BinaryOp(bin_op, lhs, rhs),
|
||||
Rvalue::BinaryOp(bin_op, box (lhs, rhs)),
|
||||
)),
|
||||
});
|
||||
terminator.kind = TerminatorKind::Goto { target };
|
||||
|
@ -139,8 +139,7 @@ impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
|
||||
let op = if f_b { BinOp::Eq } else { BinOp::Ne };
|
||||
let rhs = Rvalue::BinaryOp(
|
||||
op,
|
||||
Operand::Copy(Place::from(discr_local)),
|
||||
const_cmp,
|
||||
box (Operand::Copy(Place::from(discr_local)), const_cmp),
|
||||
);
|
||||
Statement {
|
||||
source_info: f.source_info,
|
||||
|
@ -643,7 +643,7 @@ impl<'tcx> Validator<'_, 'tcx> {
|
||||
self.validate_operand(operand)?;
|
||||
}
|
||||
|
||||
Rvalue::BinaryOp(op, lhs, rhs) | Rvalue::CheckedBinaryOp(op, lhs, rhs) => {
|
||||
Rvalue::BinaryOp(op, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(op, box (lhs, rhs)) => {
|
||||
let op = *op;
|
||||
let lhs_ty = lhs.ty(self.body, self.tcx);
|
||||
|
||||
|
@ -84,10 +84,10 @@ impl<'tcx> MirPass<'tcx> for SimplifyComparisonIntegral {
|
||||
|
||||
use Operand::*;
|
||||
match rhs {
|
||||
Rvalue::BinaryOp(_, ref mut left @ Move(_), Constant(_)) => {
|
||||
Rvalue::BinaryOp(_, box (ref mut left @ Move(_), Constant(_))) => {
|
||||
*left = Copy(opt.to_switch_on);
|
||||
}
|
||||
Rvalue::BinaryOp(_, Constant(_), ref mut right @ Move(_)) => {
|
||||
Rvalue::BinaryOp(_, box (Constant(_), ref mut right @ Move(_))) => {
|
||||
*right = Copy(opt.to_switch_on);
|
||||
}
|
||||
_ => (),
|
||||
@ -166,7 +166,10 @@ impl<'a, 'tcx> OptimizationFinder<'a, 'tcx> {
|
||||
if *lhs == place_switched_on =>
|
||||
{
|
||||
match rhs {
|
||||
Rvalue::BinaryOp(op @ (BinOp::Eq | BinOp::Ne), left, right) => {
|
||||
Rvalue::BinaryOp(
|
||||
op @ (BinOp::Eq | BinOp::Ne),
|
||||
box (left, right),
|
||||
) => {
|
||||
let (branch_value_scalar, branch_value_ty, to_switch_on) =
|
||||
find_branch_value_info(left, right)?;
|
||||
|
||||
|
@ -678,11 +678,14 @@ where
|
||||
|
||||
let one = self.constant_usize(1);
|
||||
let (ptr_next, cur_next) = if ptr_based {
|
||||
(Rvalue::Use(copy(cur.into())), Rvalue::BinaryOp(BinOp::Offset, move_(cur.into()), one))
|
||||
(
|
||||
Rvalue::Use(copy(cur.into())),
|
||||
Rvalue::BinaryOp(BinOp::Offset, box (move_(cur.into()), one)),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
Rvalue::AddressOf(Mutability::Mut, tcx.mk_place_index(self.place, cur)),
|
||||
Rvalue::BinaryOp(BinOp::Add, move_(cur.into()), one),
|
||||
Rvalue::BinaryOp(BinOp::Add, box (move_(cur.into()), one)),
|
||||
)
|
||||
};
|
||||
|
||||
@ -700,7 +703,7 @@ where
|
||||
let loop_block = BasicBlockData {
|
||||
statements: vec![self.assign(
|
||||
can_go,
|
||||
Rvalue::BinaryOp(BinOp::Eq, copy(Place::from(cur)), copy(length_or_end)),
|
||||
Rvalue::BinaryOp(BinOp::Eq, box (copy(Place::from(cur)), copy(length_or_end))),
|
||||
)],
|
||||
is_cleanup: unwind.is_cleanup(),
|
||||
terminator: Some(Terminator {
|
||||
@ -816,7 +819,10 @@ where
|
||||
self.assign(cur, Rvalue::Cast(CastKind::Misc, Operand::Move(tmp), iter_ty)),
|
||||
self.assign(
|
||||
length_or_end,
|
||||
Rvalue::BinaryOp(BinOp::Offset, Operand::Copy(cur), Operand::Move(length)),
|
||||
Rvalue::BinaryOp(
|
||||
BinOp::Offset,
|
||||
box (Operand::Copy(cur), Operand::Move(length)),
|
||||
),
|
||||
),
|
||||
]
|
||||
} else {
|
||||
|
@ -667,7 +667,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
lt,
|
||||
Rvalue::BinaryOp(BinOp::Lt, Operand::Copy(Place::from(index)), Operand::Copy(len)),
|
||||
Rvalue::BinaryOp(
|
||||
BinOp::Lt,
|
||||
box (Operand::Copy(Place::from(index)), Operand::Copy(len)),
|
||||
),
|
||||
);
|
||||
let msg = BoundsCheck { len: Operand::Move(len), index: Operand::Copy(Place::from(index)) };
|
||||
// assert!(lt, "...")
|
||||
|
@ -81,7 +81,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
is_min,
|
||||
Rvalue::BinaryOp(BinOp::Eq, arg.to_copy(), minval),
|
||||
Rvalue::BinaryOp(BinOp::Eq, box (arg.to_copy(), minval)),
|
||||
);
|
||||
|
||||
block = this.assert(
|
||||
@ -291,7 +291,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
result_value,
|
||||
Rvalue::CheckedBinaryOp(op, lhs.to_copy(), rhs.to_copy()),
|
||||
Rvalue::CheckedBinaryOp(op, box (lhs.to_copy(), rhs.to_copy())),
|
||||
);
|
||||
let val_fld = Field::new(0);
|
||||
let of_fld = Field::new(1);
|
||||
@ -324,7 +324,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
is_zero,
|
||||
Rvalue::BinaryOp(BinOp::Eq, rhs.to_copy(), zero),
|
||||
Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), zero)),
|
||||
);
|
||||
|
||||
block = self.assert(block, Operand::Move(is_zero), false, zero_err, span);
|
||||
@ -345,13 +345,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
is_neg_1,
|
||||
Rvalue::BinaryOp(BinOp::Eq, rhs.to_copy(), neg_1),
|
||||
Rvalue::BinaryOp(BinOp::Eq, box (rhs.to_copy(), neg_1)),
|
||||
);
|
||||
self.cfg.push_assign(
|
||||
block,
|
||||
source_info,
|
||||
is_min,
|
||||
Rvalue::BinaryOp(BinOp::Eq, lhs.to_copy(), min),
|
||||
Rvalue::BinaryOp(BinOp::Eq, box (lhs.to_copy(), min)),
|
||||
);
|
||||
|
||||
let is_neg_1 = Operand::Move(is_neg_1);
|
||||
@ -360,14 +360,14 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
block,
|
||||
source_info,
|
||||
of,
|
||||
Rvalue::BinaryOp(BinOp::BitAnd, is_neg_1, is_min),
|
||||
Rvalue::BinaryOp(BinOp::BitAnd, box (is_neg_1, is_min)),
|
||||
);
|
||||
|
||||
block = self.assert(block, Operand::Move(of), false, overflow_err, span);
|
||||
}
|
||||
}
|
||||
|
||||
block.and(Rvalue::BinaryOp(op, lhs, rhs))
|
||||
block.and(Rvalue::BinaryOp(op, box (lhs, rhs)))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -335,7 +335,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
||||
let result = self.temp(bool_ty, source_info.span);
|
||||
|
||||
// result = op(left, right)
|
||||
self.cfg.push_assign(block, source_info, result, Rvalue::BinaryOp(op, left, right));
|
||||
self.cfg.push_assign(block, source_info, result, Rvalue::BinaryOp(op, box (left, right)));
|
||||
|
||||
// branch based on result
|
||||
self.cfg.terminate(
|
||||
|
@ -411,7 +411,7 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
||||
self.locals[local] = self.operand_to_node(span, operand)?;
|
||||
Ok(())
|
||||
}
|
||||
Rvalue::BinaryOp(op, ref lhs, ref rhs) if Self::check_binop(op) => {
|
||||
Rvalue::BinaryOp(op, box (ref lhs, ref rhs)) if Self::check_binop(op) => {
|
||||
let lhs = self.operand_to_node(span, lhs)?;
|
||||
let rhs = self.operand_to_node(span, rhs)?;
|
||||
self.locals[local] = self.add_node(Node::Binop(op, lhs, rhs), span);
|
||||
@ -421,7 +421,9 @@ impl<'a, 'tcx> AbstractConstBuilder<'a, 'tcx> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Rvalue::CheckedBinaryOp(op, ref lhs, ref rhs) if Self::check_binop(op) => {
|
||||
Rvalue::CheckedBinaryOp(op, box (ref lhs, ref rhs))
|
||||
if Self::check_binop(op) =>
|
||||
{
|
||||
let lhs = self.operand_to_node(span, lhs)?;
|
||||
let rhs = self.operand_to_node(span, rhs)?;
|
||||
self.locals[local] = self.add_node(Node::Binop(op, lhs, rhs), span);
|
||||
|
@ -584,10 +584,10 @@ fn rvalue_locals(rvalue: &mir::Rvalue<'_>, mut visit: impl FnMut(mir::Local)) {
|
||||
match rvalue {
|
||||
Use(op) | Repeat(op, _) | Cast(_, op, _) | UnaryOp(_, op) => visit_op(op),
|
||||
Aggregate(_, ops) => ops.iter().for_each(visit_op),
|
||||
BinaryOp(_, lhs, rhs) | CheckedBinaryOp(_, lhs, rhs) => {
|
||||
BinaryOp(_, box (lhs, rhs)) | CheckedBinaryOp(_, box (lhs, rhs)) => {
|
||||
visit_op(lhs);
|
||||
visit_op(rhs);
|
||||
},
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
@ -172,7 +172,7 @@ fn check_rvalue(tcx: TyCtxt<'tcx>, body: &Body<'tcx>, def_id: DefId, rvalue: &Rv
|
||||
}
|
||||
},
|
||||
// binops are fine on integers
|
||||
Rvalue::BinaryOp(_, lhs, rhs) | Rvalue::CheckedBinaryOp(_, lhs, rhs) => {
|
||||
Rvalue::BinaryOp(_, box (lhs, rhs)) | Rvalue::CheckedBinaryOp(_, box (lhs, rhs)) => {
|
||||
check_operand(tcx, lhs, span, body)?;
|
||||
check_operand(tcx, rhs, span, body)?;
|
||||
let ty = lhs.ty(body, tcx);
|
||||
|
Loading…
Reference in New Issue
Block a user