]> git.lizzy.rs Git - rust.git/commitdiff
Don't perform neg overflow checks when they are disabled
authorbjorn3 <bjorn3@users.noreply.github.com>
Tue, 20 Aug 2019 11:37:49 +0000 (13:37 +0200)
committerbjorn3 <bjorn3@users.noreply.github.com>
Sat, 7 Sep 2019 09:00:49 +0000 (11:00 +0200)
src/base.rs

index 48fe920204e7b4110a065bd8d167af97d5c5d66a..68ca6cffbef6ccb840616a385fd74c0b74691312 100644 (file)
@@ -162,6 +162,13 @@ fn codegen_fn_content(fx: &mut FunctionCx<'_, '_, impl Backend>) {
                 target,
                 cleanup: _,
             } => {
+                if !fx.tcx.sess.overflow_checks() {
+                    if let mir::interpret::PanicInfo::OverflowNeg = *msg {
+                        let target = fx.get_ebb(*target);
+                        fx.bcx.ins().jump(target, &[]);
+                        continue;
+                    }
+                }
                 let cond = trans_operand(fx, cond).load_scalar(fx);
                 // TODO HACK brz/brnz for i8/i16 is not yet implemented
                 let cond = fx.bcx.ins().uextend(types::I32, cond);