diff options
author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2023-03-16 00:00:00 +0000 |
---|---|---|
committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2023-03-16 22:55:45 +0100 |
commit | 27b430bcb36e46cc5dcfd88ec6cec2639ad2467c (patch) | |
tree | 9bb26a194c35f8cfa1b4141210a21e14d63e1bd9 /compiler/rustc_codegen_cranelift | |
parent | e386217dd996d293b3bde2285f6f5f4f502d7c17 (diff) | |
download | rust-27b430bcb36e46cc5dcfd88ec6cec2639ad2467c.tar.gz |
Tweak implementation of overflow checking assertions
Extract and reuse logic controlling behaviour of overflow checking
assertions instead of duplicating it three times.
Diffstat (limited to 'compiler/rustc_codegen_cranelift')
-rw-r--r-- | compiler/rustc_codegen_cranelift/src/base.rs | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index d0af3729b23..1b8e9312e2f 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -346,17 +346,10 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { crate::abi::codegen_return(fx); } TerminatorKind::Assert { cond, expected, msg, target, cleanup: _ } => { - if !fx.tcx.sess.overflow_checks() { - 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; - } + if !fx.tcx.sess.overflow_checks() && msg.is_optional_overflow_check() { + let target = fx.get_block(*target); + fx.bcx.ins().jump(target, &[]); + continue; } let cond = codegen_operand(fx, cond).load_scalar(fx); |