diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-02-15 18:46:56 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-02-18 21:35:02 +0000 |
| commit | 39068eb1cc172335f9f3933cba0008bc263ce3ab (patch) | |
| tree | 25a6d16875462c125d1b359191246a4b4e57f598 | |
| parent | 8fe8e533009adda27754abf05af6ed623f7e9c86 (diff) | |
| download | rust-39068eb1cc172335f9f3933cba0008bc263ce3ab.tar.gz rust-39068eb1cc172335f9f3933cba0008bc263ce3ab.zip | |
Adapt cg_clif.
| -rw-r--r-- | src/base.rs | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/src/base.rs b/src/base.rs index 95778de3aba..7f857528c7c 100644 --- a/src/base.rs +++ b/src/base.rs @@ -347,7 +347,12 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { } TerminatorKind::Assert { cond, expected, msg, target, cleanup: _ } => { if !fx.tcx.sess.overflow_checks() { - if let mir::AssertKind::OverflowNeg(_) = *msg { + let overflow_not_to_check = match msg { + AssertKind::OverflowNeg(..) => true, + AssertKind::Overflow(op, ..) => op.is_checkable(), + _ => false, + }; + if overflow_not_to_check { let target = fx.get_block(*target); fx.bcx.ins().jump(target, &[]); continue; @@ -567,15 +572,7 @@ fn codegen_stmt<'tcx>( let lhs = codegen_operand(fx, &lhs_rhs.0); let rhs = codegen_operand(fx, &lhs_rhs.1); - let res = if !fx.tcx.sess.overflow_checks() { - let val = - crate::num::codegen_int_binop(fx, bin_op, lhs, rhs).load_scalar(fx); - let is_overflow = fx.bcx.ins().iconst(types::I8, 0); - CValue::by_val_pair(val, is_overflow, lval.layout()) - } else { - crate::num::codegen_checked_int_binop(fx, bin_op, lhs, rhs) - }; - + let res = crate::num::codegen_checked_int_binop(fx, bin_op, lhs, rhs); lval.write_cvalue(fx, res); } Rvalue::UnaryOp(un_op, ref operand) => { |
